How to Environment the Assembly is running in

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to find using code, the environment the dll(Assembly) is runnign from.
suppose i create an Assembly in .NET, then that assembley might be running
under IIS or Webservice or Remoting or windows service or as a part of
standard exe
How can i find where assembly is running from
 
I don't think there is a standard way.

You could, for instance, tell if it running from a website by checking
something like the HttpContext.Current, which will be null if it is not. I
do not think you can determine the difference between a service and console
app as they are both executables.

You can always fake the system by like setting some variable in the OnStart
which will only be set when it is running as a service.
 
Back
Top