Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot start service from the command line or a debugger

Status
Not open for further replies.

BaggersHome

Programmer
Oct 10, 2004
2
GB
Hi,

I have a C#.NET solution with a service and a windows project. I have installed the service using installutil.exe and I have gone into services (Start->Run "services"), verified it's there and started it.

I have connected the sevice to the form application by dragging the service from the services view in VS.NET 2003 onto the form, I have entered a "Name" for the sevice and specified the ServiceName property as the Service Name property when you right click on the service in the Services manager.

However, when I try and debug the solution I get the following error:

"cannot start service from the command line or a debugger. A Windows service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Service Adminitrative Tool or the NET START command."

I am running Windows XP. There is only one page of Google results on this and all those were where people had not installed/started the service, any ideas?

Cheers,
Steve.
 
To debug a service you must:

1) Start the service.
2) Go to VS.NET and attach ( Debug -> Processes -> Attach) to it.
3) Close the "Processes" windows and if attach was successfull, you should be in debug mode on that service.
4) Note that you can't debug some methods (such as OnStart), so if you need to debug code that gets executed in the "OnStart" method, move its functionality in another method and call it from OnStart.
 
Thanks B00gyeMan,

Thanks, that worked just as you said, but my problem was far simpler: I had the service and not the windows app as the Startup Project! I apologise, but in my defense I am a newbie!

Thanks again.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top