Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My c# project is in my local machine ( in dvelopment environment ).I want to debug my code but its saying "a project with an output type of clas library canot be started directly" "inorder to debug this project add an executable project to this solution which references the library project". because i'm debuging the code in the develpment envirnment i dont have the adUserSync or indexer in my machine. what is the syntax for starting the services in my code in my machine without puting my code to production and debug.
Posted

There is no such syntax. The Windows Service is hosted in a different way and is run by Windows Service Controller. To get to this point, you need to install you Service application in a proper way. Then you need to use system "Services" applet (services.msc) to start the service.

In order to install service, you need to program your service application "installable". In fact, you can develop your application the way it can be used as an interactive application and a Windows Service, depending on how it is run. If you do that, you can include installation code and optionally the code working with the Service Controller to start/stop/restart your service. These two chores can be implemented in the interactive part of your application (or a separate application, of course).

Please see my past solution on more detail:
How to install windows service programmatically[^].

—SA
 
Share this answer
 
v2
So you're writing a Windows Service[^], and you're trying to debug it?

As the message implies, your project needs to be configured as a Console Application. This is changed in the project's Properties dialog.

You can't easily debug a service from the IDE, but this is a good reference: How to: Debug Windows Service Applications[^]

If possible, just run it as a normal console application until you're ready to make it a service. When it's ready you can install it as a service from the command line using sc[^] or programatically using an Installer with custom actions[^].

This is a good overview of the whole process: Introduction to Windows Service Applications[^]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900