WPF アプリケーションにいくつかの WCF サービスがあり、次の方法でそれらを開きます。
private void StartSpecificWCFService(IService service, string url, Type serviceInterfaceType)
{
ServiceHost serviceHost = new ServiceHost(service, address);
serviceHost.AddServiceEndpoint(serviceInterfaceType, new NetNamedPipeBinding(), url);
serviceHost.Open();
//sign to serviceHost.Faulted ??
_wcfServicesHolder.Add(serviceHost); //A dictionary containing all my services
}
サービス属性は次のとおりです。
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
サービスはログ サービスとイベント サービスであり、他のプロセスから多くの呼び出しを受けます。名前付きパイプが最速であり、プロセスが同じコンピューターで実行されるため、名前付きパイプを使用します。
私の質問は、これらのサービスを常に稼働させるにはどうすればよいですか?
- _wcfServicesHolder を反復し、サービスが開いているかどうかを確認するポーリング タイマー
- serviceHost.Faulted イベントに署名します。
また、サービスが障害状態になった後、(別のプロセスで) クライアントを再作成する必要がありますか? または、同じチャネルでメッセージをブロードキャストできますか?
私が受け取る例外は次のとおりです。
There was no endpoint listening at net.pipe://localhost/LoggingService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details