Windows Service in C# does not get service name in argv[0]

Hello, in my current services written in c/c++ the SCM passes the service name as the first argument to Main(int ac,char **av). av[0] is always the servicename. However, in c# I only get arguments I put in the ImagePath registry entry for the service. This prevents me from having mutliple instances of a service unless I modify the registry upon installing the services. Is this an issue with .NET? Thanks.
[520 byte] By [JohnMcIntyre] at [2007-12-28]
# 1

Yes this is .NET. The process name is not put into the argv[0] anymore. This value is rarely needed anyway for command line processing.

Instead you can call

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName

to retrieve your executable name.

Yours,

Alois Kraus

Alois at 2007-9-4 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 2

Thank you for the reply. However, this gives me the executable name and not the service name. Multiple services can point to the same exe. I found that I can add args to the registry entry and pass in a instance number.

JohnMcIntyre at 2007-9-4 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 3
There were so many things I could get out of c/c++ that I can't under .NET Is this changed in .Net 3.0? Anyone come up with a solution to getting the service name?
Bert at 2008-1-31 > top of Msdn Tech,.NET Development,Common Language Runtime...

.NET Development

Site Classified