且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows无法在本地计算机上启动该服务。

更新时间:2022-04-12 22:15:01

在设计模式下。右键单击 - >添加安装程序。我们得到文件ProjectInstaller。我们可以看到两个,ServiceProcessInstall1和ServiceInstaller1。



点击F7,看看

In design mode. Right click --> Add Installer. We get the file ProjectInstaller. We can see two, ServiceProcessInstall1 and ServiceInstaller1.

Click F7 and see
[RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
        }
    }
}





右键单击InitializeComponent();选择转到定义(F12)你可以去





Right Click at InitializeComponent(); choose Go to Definition (F12) You can go to

/// </summary>
       private void InitializeComponent()
       {
           this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
           this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
           //
           // serviceProcessInstaller1
           //
           this.serviceProcessInstaller1.Password = null;
           this.serviceProcessInstaller1.Username = null;
           //
           // serviceInstaller1
           //
           this.serviceInstaller1.ServiceName = "Service1";
           //
           // ProjectInstaller
           //
           this.Installers.AddRange(new System.Configuration.Install.Installer[] {
           this.serviceProcessInstaller1,
           this.serviceInstaller1});

       }





并按上述方式更改。它的工作原理



and change it like above. It works


请试试这个:



Please try this:

this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;

this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "TimerThreadService";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;


两件事

1)确保所有相关服务都已启动。

2)你有足够的可用内存。
Two things
1) Make sure any dependent services are started.
2) You have enough free memory.