views:

49

answers:

2

Hi guys,

I have created windows service project in vs2008.

  • I have created simple serivce project and implemented simple serivce sucessfully.
  • Unlike other application i cannot run service exe file, so I had to first installed service using ServiceInstaller in my service project.
  • Now i am building setup project for my service (MSI). In that setup project I am trying to add the output from my service project to my setup project by follwing below step

1. Right Click **Setup roject** in solution explorer and then click add and then click project output. 2.Now it open up *project output group dialog box* but now problem is this dialog box is empty and not allowing me to select service project. Now i dont know how to add the service projet to my setup project any help would be appriciated. Thank you guys.

A: 

one way to be able to run and test a windows service in VS without having to install it is to instantiate and call your service class's primary method using #if Debug statement

static void Main()
{
#if (!DEBUG)
//If not Debug run as Service
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new TestService() };
ServiceBase.Run(ServicesToRun);

#else
    // if debug run your services primary method
    Service1 service = new Service1();
    service.<Your Service's Primary Method Here>();
#endif
}
derek
+1  A: 

Here's a good walk through of what you need to do.

I'm not entirely sure why you're not seeing your service project's output. Make sure your service project is selected in the drop down list.

Also to note, one of the steps I always seem to miss is the custom actions. You have to hook up your service installer to the custom actions to actually get it to install as a service.

Aaron Daniels
vijay shiyani