简体   繁体   中英

VS 2008 Windows Service Installer Doesn't work

I just created a new windows service and I am having issues with the installer.

I created the installer via this tutorial: http://www.sarin.mobi/2008/08/c-windows-service-visual-studio-2008/

Anyway, when I run the .msi generated by VS, the executable for this project is installed where I expect it to be. However, the service does not appear in Windows Services.

When I use the VS command line tool and installutil, everything works just fine.

I have created services in the past, so I compared the ProjectInstaller files and the installer configuration with past projects and see no significant differences.

Any advice?

To install a service, you need to add a ServiceInstaller and a ServiceProcessInstaller to the service project, then add custom actions to the installer to run them. I'm pretty sure it's the custom actions part you're missing.

  1. Create a new Windows Service project
  2. Double-click on the .svc file to open the designer.
  3. Right-click on the design surface and pick 'Create Installer'. This will create one of each.
  4. Set the properties... key props are:
    • ServiceInstaller: Name and Startup Type
    • ServiceProcessInstaller: Account to run under.
  5. Create your setup project
  6. Right-click on the setup project and pick Add -> Project Output
  7. Pick the service project from the drop-down and pick 'Primary Output'
  8. Right-click on the setup project and pick View -> Custom Actions
  9. Right-click on the Custom Actions tree that appears and pick Add Custom Action
  10. Pick 'Application Folder'
  11. Pick 'Primary Output From Service'
  12. Click 'Ok'. Four actions will be added, one under each Install Action

Now when you build the installer and execute it, the installers you've created in step 3 will be executed, adding your service and setting all properties.

HTH,
James

Step-by-step instructions for creating a Windows service in C# using Visual Studio 2008 can be found here . This includes the addition of the Installers necessary to install the service using the InstallUtil.exe utility.

If you want to have your service install itself via the command line, see the step-by-step instructions here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM