Is there a way for my ASP.net Application to know if it’s running within SharePoint (2010), but without referencing SharePoint Assemblies? (So I can’t just check if SPContext.Current is null).
I wonder if it’s viable to get all Assemblies that are loaded by name? So if I see that my AppDomain contains a Microsoft.SharePoint assembly then I know I’m in SharePoint.
Use case: The Assembly runs outside of SharePoint as well, but referencing SharePoint DLLs requires to deploy them (not possibly due to licensing) or getting Exceptions when I access a SharePoint method.
At the moment I use conditional compilation, but I’d like to get away from that and use a DI-mechanism to choose one of two classes, depending if I’m in SharePoint.
Untested, but this would perform the check for a loaded assemblies whose name was Microsoft.SharePoint.