We help IT Professionals succeed at work.

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?
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
What does your OnStart method look like in your service code?

Author

Commented:
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.
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
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  = )
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:

Author

Commented:
They worked.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.