chadmanvb
asked on
run a .net 2.0 exe as a service
I have a console application I wrote with .net 2.0 and have a Windows service call this .exe. When I try to start the service it comes back with an error telling me it could not start the service in a timly manner. However, the .exe still runs and works. Would can I add to my console application so windows can see the service start?
What does your OnStart method look like in your service code?
ASKER
This .exe is not really written as a service. I used SRVANY.EXE
to created the service and have it point to my console application. I just wanted to test it running under the system id. In the future it will be triggered by SCOM agent that does run as a service. I guess I might not even see this when SCOM runs it.
to created the service and have it point to my console application. I just wanted to test it running under the system id. In the future it will be triggered by SCOM agent that does run as a service. I guess I might not even see this when SCOM runs it.
Ah. I know that when you write a windows service from scratch, usually when you receive that particular error it is because you are doing some long-running logic in the service initialization section. This section has to return to the OS in a particular amount of time--roughly 15 seconds. If it does not return in a timely fashion, then the OS complains with the error you mention.
Unfortunately, I am not familiar enough with srvany.exe, although I do understand what it is supposed to do. I wouldn't expect what I described here to be the case if you are using that utility. Please hold out for someone more versed with that particular utility to answer = )
Unfortunately, I am not familiar enough with srvany.exe, although I do understand what it is supposed to do. I wouldn't expect what I described here to be the case if you are using that utility. Please hold out for someone more versed with that particular utility to answer = )
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
They worked.