You can use System.Environment.UserInteractive. If this is False, the
program is running as a service.

Urs


> -----Ursprüngliche Nachricht-----
> Von: Saar Carmi [mailto:[EMAIL PROTECTED]]
> Gesendet: Sonntag, 13. Oktober 2002 16:25
> An: [EMAIL PROTECTED]
> Betreff: [ADVANCED-DOTNET] Is code running under a service?
> 
> 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.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to