Error 5 : Access Denied when starting windows service

前端 未结 30 2517
滥情空心
滥情空心 2020-12-04 18:49

I\'m getting this error when I try to start a windows service I\'ve created in C#:

\"alt

My Code

30条回答
  •  余生分开走
    2020-12-04 19:29

    After banging my had against my desk for a few hours trying to figure this out, somehow my "Main" method got emptied of it's code!

    ServiceBase[] ServicesToRun;
    ServicesToRun = new ServiceBase[] 
    { 
        new DMTestService()
    };
    ServiceBase.Run(ServicesToRun);
    

    Other solutions I found:

    • Updating the .NET framework to 4.0
    • Making sure the service name inside the InitializeComponent() matches the installer service name property

      private void InitializeComponent()
      ...
      this.ServiceName = "DMTestService";
      
    • And a nice server restart doesn't hurt

    Szhlopp

提交回复
热议问题