Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF通信对象何时出现故障?_C#_Wcf_Error Handling_Fault - Fatal编程技术网

C# WCF通信对象何时出现故障?

C# WCF通信对象何时出现故障?,c#,wcf,error-handling,fault,C#,Wcf,Error Handling,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

假设我们有一个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
var-host=newservicehost(typeof(MyService));
AddServiceEndpoint(typeof(IMyService)、新的NetNamedPipeBinding()、新的Uri(hostUrl));
host.Open();
var cf=new ChannelFactory(new NetNamedPipeBinding(),new EndpointAddress(hostUrl));
var ch=cf.CreateChannel();
//断点在这里
假设所有对象都已成功创建、打开并且我们现在处于断点,那么实际上这三个通信对象何时会出现故障

如果在执行过程中引发任何异常,我们的频道将切换到通信状态。出现故障。
这是可以的,因为我们从不重用通道,并且不会影响通道工厂和主机


最后两个呢?什么可以使它们切换到故障状态

这是一个很好的问题!有一些有趣的阅读是关于当它们出现故障时如何处理的,但没有太多关于为什么。如