How to install a Windows service developed in .NET 3.5?

前端 未结 4 1769
不知归路
不知归路 2021-02-04 15:12

I have developed a Windows service using Visual Studio 2008. I want to install that service in a machine where Visual Studio is not installed, but .NET 3.5 is installed.

相关标签:
4条回答
  • 2021-02-04 15:26

    If you've been using InstallUtil.exe to install your Windows service, then that means you've added a ProjectInstaller component to your service. All the InstallUtil.exe does is use reflection to find the installer component embedded in your service and execute some methods on it. Due to this, you can modify your Windows service to install and uninstall itself, i.e., you no longer have to depend on InstallUtil.exe being available on the target machine. I've been using this successfully for several months now. Just follow the step-by-step I provided here. The idea originally belongs to Marc Gravell and this post.

    0 讨论(0)
  • 2021-02-04 15:29

    The message:

    "Error 1053: The service did not respond to the start or control request in a timely fashion."

    is typically a generic response to an issue starting the Windows Service. What you should do is check the event log and likely you will find the real error that is preventing the service from starting.

    0 讨论(0)
  • 2021-02-04 15:35

    It's actually really simple as I just did it a couple of days ago for something I made.

    So in your service project you want to:

    1. In the solution explorer double click your services .cs file. It should bring up a screen that is all gray and talks about dragging stuff from the toolbox.
    2. Then right click on the gray area and select add installer. This will add an installer project file to your project.
    3. Then you will have 2 components on the design view of the ProjectInstaller.cs (serviceProcessInstaller1 and serviceInstaller1). You should then setup the properties as you need.

    Now you need to make a setup project. The best thing to do is use the setup wizard.

    1. Right click on your solution and add a new project: Add > New Project > Setup and Deployment Projects > Setup Wizard
    2. On the second step select "Create a Setup for a Windows Application."
    3. On the 3rd step, select "Primary output from..."
    4. Click through to Finish.

    Now you need to edit your installer to make sure the correct output is included.

    1. Right click on the setup project in your Solution Explorer.
    2. Select View > Editor > Custom Actions.
    3. Right-click on the Install action in the Custom Actions tree and select 'Add Custom Action...'
    4. In the "Select Item in Project" dialog, select Application Folder and click OK.
    5. Click OK to select "Primary output from..." option. A new node should be created.
    6. Repeat steps 4 - 5 for commit, rollback and uninstall actions.

    Now just build your installer and it will produce an MSI and a setup.exe. Choose whichever you want to use to deploy your service.

    0 讨论(0)
  • 2021-02-04 15:45

    There's a Microsoft KB on this for .Net 2.0 and VS2005. The procedure is exactly the same in .Net 3.5 and VS2008.

    http://support.microsoft.com/kb/317421

    And here's a nicer article with pictures to make it clearer. (Sometimes the KB's aren't as friendly as tutorials you can find elsewhere.)

    http://aspalliance.com/1316_Working_with_Windows_Service_Using_Visual_Studio_2005.3

    0 讨论(0)
提交回复
热议问题