When do they become WCF communication objects?

Suppose we have a WCF host, a factory channel, and a channel:

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

Assuming that all objects are successfully created, open, and now we are at a breakpoint, when in fact these three communication objects can become faulty?

Our channel will switch to CommunicationState.Faultedif an exception is thrown at runtime.
This is normal, since we never use channels, and this does not affect the factory channel and host.

What about the last two? What can cause them to enter the Faulted state?

+4
source share

All Articles