管理対象のWindowsサービス経由で展開されるwcfサービスを作成しました。 onstart()が行うことは、wcf serice用のtcpホストを作成してオープンすることです。WindowsサービスはWindows 7で起動しますが、Windows Server 2008 R2では起動できません
Windows 7ではすべて正常に動作しますが、Windows Server 2008 R2にサービスをインストールしようとするとサービスが開始され、何もしなくてもサービスが停止するというエラーが発生して停止します。これは、ネットワークサービスアカウントで実行されます。
Windowsのログで何か便利なものは見つかりません。
私はdubugビルドをインストールしようとしましたが、debugger.launch()を呼び出しても動作しません。プロセスが私がそれに接続するのに十分長い間開いていないので、私はデバッグを使用しないでください。 私は本当に何をすべきか分かりません。ここに私のコードは次のとおりです。
protected override void OnStart(string[] args)
{
System.Diagnostics.Debugger.Launch();
try
{
//if (!System.Diagnostics.EventLog.SourceExists("i2s CU Service (eng)"))
//{
// System.Diagnostics.EventLog.CreateEventSource("i2s CU Service", "Application");
//}
System.Diagnostics.EventLog.CreateEventSource("i2s CU Service", "Application");
}
catch (Exception)
{
//throw;
}
eventLog1.Source = "i2s CU Service";
eventLog1.Log = "Application";
if (serviceHost != null)
{
serviceHost.Close();
}
System.Configuration.AppSettingsReader reader = new System.Configuration.AppSettingsReader();
Uri tcpUri = null;
try
{
tcpUri = new Uri((string)reader.GetValue("Uri", typeof(string))); //net.tcp://localhost:8008/i2sServer
serviceHost = new ServiceHost(typeof(ConcurrentUsers), tcpUri);
// Create a binding that uses TCP and set the security mode to none.
NetTcpBinding b = new NetTcpBinding();
b.Security.Mode = SecurityMode.None;
// Add an endpoint to the service.
serviceHost.AddServiceEndpoint(typeof(IConcurrentUsers), b, "");
// Open the ServiceHostBase to create listeners and start
// listening for messages.
serviceHost.Open();
}
catch (Exception ex)
{
eventLog1.WriteEntry(ex.Message, EventLogEntryType.Error);
}
if (serviceHost.State == CommunicationState.Opened)
{
eventLog1.WriteEntry("Service started.", EventLogEntryType.Information);
}
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Close();
serviceHost = null;
}
eventLog1.WriteEntry("Service stopped.", EventLogEntryType.Information);
}
このコードがあるとして、Windows 7で完全に正常に動作しますが、私はそれが勝利2008 R2サーバー上で実行するために取得傾けます。事前
、問題がすぐそこに起こることができるあなたの窓に割り当てられているのと同じユーザーアカウントで、コンソールレプリカを実行したら、問題は自分自身を明らかにすることを確信しています。 – vulkanino
私はエラーログ全体を削除しようとしましたが、それでも同じです – Ares
これは、Windows 7とそれが起動しない前に述べたデバッガの問題ではないようです! – Ares