5

Suppose, we have a WCF host, channel factory and 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, opened and we are now at the breakpoint, when actually these three communication objects can become faulted?

Our channel will switch to CommunicationState.Faulted if any exception is thrown during execution.
It is OK since we never reuse channels and it does not affect the channel factory and host.

What about the last two? What can make them switch to Faulted state?

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
  • 1
    Thats a great question! There's some interesting reading about how to handle it when they do go faulty, but not much on why. Eg http://stackoverflow.com/q/315736/569662 – tom redfern Apr 13 '16 at 09:29

0 Answers0