Fork me on GitHub

Failed to open System.ServiceModel.ChannelFactory Solution 2


I just ran into this one today while trying to call a WCF service. Doing a search of this on Google/Bing literally yields 3-4 results so I figured I better post something about it in case anyone else comes across it.


First off you might also see it in conjunction with an exception like:

The communication object, System.ServiceModel.ChannelFactory`1[T], cannot be used for communication because it is in the Faulted state.

The above exception isn’t very useful by its self though because in my experience A LOT of WCF issues manifest themselves this way.

I also got an System.IO.FileNotFoundException (“Could not load file or assembly…The system cannot find the file specified.”) which was very confusing because I was just trying to spin up an service contract interface using a ChannelFactory. More on this later…


Some steps I took to resolve the issue:

  1. Verify that both the client and the server have the same [ServiceContract], [OperationContract](s), [DataContract] and [DataMember] definitions. We are using an assembly that is shared with both the client and server rather than a “service reference” in Visual Studio.
  2. Ensure that your WCF binding configurations match EXACTLY (to start out with at least) in the <services> section in the service and your <client> section on your client.
  3. Try calling your service with WCF Test Client and see if it works. This was the annoying part about this issue for me… WCF Test Client worked just fine!


My Solution

I took a much closer look at the service contract classes and solution and noticed some [CustomAttributes] on some [DataMember] properties in some of the [DataContract]s. I then realized that my client did not have reference to the assembly defining these attributes. I added a reference to the assembly defining these [CustomAttributes] and everything started working… finally! This also explained the FileNotFoundException I was experiencing… whoops!

What I found surprising about this issue is that WCF wasn’t able to create a ChannelFactory simply because I didn’t have reference to an attributes, (not actual [DataMember] property type definitions). It seems that WCF actually does some sort of a serialization on these [CustomAttributes] because it simply didn’t work. This is interesting of course because an attribute can only contain constants so why would it need to have any sort of serialization, hmm… This all makes me wonder a little bit what is going on behind the scenes with attributes on [DataMember] properties.

Hope this helped someone having a similar issue!

2 thoughts on “Failed to open System.ServiceModel.ChannelFactory Solution

  1. Reply Eileen Sep 18, 2014 5:50 am

    Wonderful blog! Do you have any recommendations for aspiring writers?

    I’m planning to start my own blog soon but I’m a little lost on everything.
    Would you advise starting with a free platform like WordPress or go
    for a paid option? There are so many options out there
    that I’m completely overwhelmed .. Any tips? Many

  2. Reply Brion Nov 23, 2012 11:27 am

    Hello, I was looking on the web and I found your site. Keep up the good work. %))

Leave a Reply