Yel*_*yev 5 c# error-handling wcf fault
假设,我们有一个 WCF 主机、频道工厂和频道:
var host = new ServiceHost(typeof(MyService));
host.AddServiceEndpoint(typeof(IMyService), new NetNamedPipeBinding(), new Uri(hostUrl));
host.Open();
var cf = new ChannelFactory<IMyService>(new NetNamedPipeBinding(), new EndpointAddress(hostUrl));
var ch = cf.CreateChannel();
// The breakpoint is here
Run Code Online (Sandbox Code Playgroud)
假设所有对象都已成功创建、打开并且我们现在处于断点处,那么这三个通信对象实际上何时会出现故障?
CommunicationState.Faulted如果在执行过程中抛出任何异常,我们的通道将切换到。
没关系,因为我们从不重用通道并且它不会影响通道工厂和主机。
最后两个呢?什么可以使他们切换到故障状态?