Install Windows Service created in Visual Studio

前端 未结 7 706
Happy的楠姐
Happy的楠姐 2020-12-02 06:16

When I create a new Windows Service in Visual Studio 2010, I get the message stating to use InstallUtil and net start to run the service.

I have tried the following

7条回答
  •  庸人自扰
    2020-12-02 06:36

    Another possible problem (which I ran into):

    Be sure that the ProjectInstaller class is public. To be honest, I am not sure how exactly I did it, but I added event handlers to ProjectInstaller.Designer.cs, like:

    this.serviceProcessInstaller1.BeforeInstall += new System.Configuration.Install.InstallEventHandler(this.serviceProcessInstaller1_BeforeInstall);

    I guess during the automatical process of creating the handler function in ProjectInstaller.cs it changed the class definition from

    public class ProjectInstaller : System.Configuration.Install.Installer

    to

    partial class ProjectInstaller : System.Configuration.Install.Installer

    replacing the public keyword with partial. So, in order to fix it it must be

    public partial class ProjectInstaller : System.Configuration.Install.Installer

    I use Visual Studio 2013 Community edition.

提交回复
热议问题