In a .Net web service is it possible to determine if the assembly was loaded inside a web service? If it is, how would such a check be made? And from such a check can the original location of the assembly be determined?
It's a long story involving assemblies being shared between multiple entry points of our application on a server some of which are exposed through web services and others are exposed through more traditional TCP sockets hosted inside of normal Windows services. There may also be other Windows services running using the same shared assemblies. The configuration needs of each are slightly different and calls like System.Windows.Forms.Application.ExecutablePath yield different results depending on what is "hosting" the assembly. I need to be able reliably calculate the assembly's location to calculate the location of the configuration file.
Web.config / app.config are not options in this scenario.
It would be possible to put an entry into the registry that could be used to determine where the application(s) and all assemblies are located. But this wouldn't be as desirable as having the application(s) calculate locations themselves.
EDIT:
Let's that foo.dll can be called from both MyApp.asmx (the web service) and MyService.exe (the Windows service). Is there anyway to determine if MyApp.asmx was the application that loaded foo.dll from the code-behind (MyApp.dll)?