私のソリューションではreg
、アプリを起動するためのコンソール プロジェクトがあり、正常に動作します
コンソールを Windows サービスに置き換えたいのですService1
が、機能せず、データベースに接続する際にエラーが発生します
これが私の解決策であり、Service1 item
代わりにコンソールを使用しますreg
これが私のonStart
方法です
protected override void OnStart(string[] args)
{
System.Diagnostics.Debugger.Launch();
EventLog.WriteEntry("Service Started...");
ConfigureServer();
}
ここで、 ログインによって要求されたデータベース xds を実行できないという問題が発生します
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();
}