Hi All
Do you think the following code is a good way to determine if the code is
running under a service or not?
<snip>
Assembly assembly = Assembly.GetEntryAssembly();
MethodInfo mainMethod = assembly.EntryPoint;
Type entryPointType = mainMethod.GetType();
if (entryPointType.GetType().IsSubclassOf (typeof
(System.ServiceProcess.ServiceBase)))
{
Console.WriteLine ("Service");
}
else
{
Console.WriteLine ("Not Service");
}
</snip>
Can you think of a better idea?
Thanks,
Saar Carmi
You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.