简体   繁体   中英

Convert from console to windows service error

in my solution i have a console project reg to start my app and it works fine

now i want to Replace console to a windows service Service1 but it doesn't work and give me an error to connect with database

this is my solution and i use Service1 item instead Console reg

在此处输入图片说明

and this is my onStart Method

      protected override void OnStart(string[] args)
      {
            System.Diagnostics.Debugger.Launch();
                 EventLog.WriteEntry("Service Started...");
                 ConfigureServer();
      }

Here, the problem occurs cannot run database xds requested by the login

 using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create())
                     {
                          powershell.Runspace = myRunSpace;
                          powershell.Commands.AddScript("Get-CsTrustedApplicationPool");
                          Collection<PSObject> results = null;
                          Collection<ErrorRecord> errors = null;
                          try
                          {
                                results = powershell.Invoke();
                                errors = powershell.Streams.Error.ReadAll();
                          }

On which account your service is running?

在此处输入图片说明

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