Can a ChannelFactory become Faulted?
Asked Answered
B

1

9

Let's say i'm caching a ChannelFactory<T> and using it to create channels. These channels are used to make WCF calls to other services, and are then being (safely) disposed.

Do I need to worry about a situation where the cached ChannelFactory becomes faulted and thus unusable for creating new channels? if so, do I need to replaced it with a new ChannelFactory?

I would also appreciate a reproducible concrete example for a case where a ChannelFactory becomes faulted.

Bulk answered 20/12, 2012 at 15:23 Comment(3)
If concerned you could always check the state prior to accessing as good measure as to not access a channel that has been Closed or Faulted.Managerial
@Managerial I am talking about the ChannelFactory being faulted and not the channel.. I don't want to implement logic the recreates channel factories if i don't have to...Bulk
I was just about to ask the same question. It seems to me that as long as your individual channels are properly handled, the only faults you would see in ChannelFactory would occur during instantiation of the class. Have you run into any additional issues since?Jobe
G
1

I don't think that you need to worry about Faulted state in that case. ChannelFactory changes its state to Faulted when it has problems during opening (what could happen when you call the Open() method or create the first channel without calling Open()).

var factory = new ChannelFactory<ITestService>();
try
{
    factory.Open();
}
catch
{
    Console.WriteLine(factory.State);
}
Greengrocer answered 5/9, 2014 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.