我有一个继承自ServiceBase的MyServiceBase类.在MyService内部我有一个ServiceHost用于我的WCF服务,只有一个方法具有IsOneWay = true属性.我用这段代码初始化它:
host = new ServiceHost(typeof(MyService)); host.Opened += new EventHandler(host_Opened); host.Closed += new EventHandler(host_Closed); host.Faulted += new EventHandler(host_Faulted); host.UnknownMessageReceived += new EventHandler<UnknownMessageReceivedEventArgs>(host_UnknownMessageReceived); host.Open();
有时主机会引发Faulted事件,但* host_Faulted *方法中的EventArgs总是为空,所以我找不到它的原因.
请帮忙.
谢谢你.
解决方法
此链接可能对更好的WCF故障处理和调试方式有用:
How do I prevent a WCF service from enter a faulted state?
因此,我建议您更好地实现您的要求,而不是回答您的具体问题.