Answer
Services that rely on the presence of an assembly in the Global Assembly Cache (GAC) cannot be installed or started during the execution of StartServices standard action. If you need to start a service that depends on an assembly in the GAC, you must use a custom action scheduled after the InstallFinalize standard action.
In this example we will use a .bat file for our custom action.
- Create a .bat file and paste the following code:
net start "Service Name"
The "Service Name" must match the declared "Service Name:" field of
your service.
- Add your .bat file to the project as a temporary file.
- Select your service control operation from the Services Page and uncheck the "Start" checkbox in "Event on Install" field.
- Go to the Custom Actions Page and add "Launch File or Open URL" after "Finish Execution" action group from "Install Execution Stage". Select the button and select your bat file.
- Build your project and run it.