WCF Service References not generating web.config client endpoints and bindings


I hate to admit it, but I spent a few hours pulling my hair out on this one. I created a new WCF Service and added a few services. I then added a service reference to some small consuming applications and everything worked fine. I then added a service reference to a large website which has about ~50 referenced assemblies. This time when I did it, my web.config serviceModel section wasn’t updated by Visual Studio 2010. Normally, Studio will generate bindings and client end points for you. What the hell! I was baffled.

I soon discovered that the website wouldn’t compile with this WCF service reference either, which was odd because I obviously hadn’t written any consuming code for it yet. The compiler error was this:

Parser Error Message: Reference.svcmap: Failed to generate code for the service reference XXXXOrderService’.
Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:

Error: Could not load file or assembly …


As it turns out, the problem was happening because Reuse types in all referenced assemblies was enabled in the service reference settings, which is is enabled by default. Well, that wasn’t WHY the error was occurring and I haven’t taken the time to become well versed enough in this matter (behind on a deadline), but this can apparently cause issues if both the consuming application and the WCF service reference the same assemblies. I didn’t actually spend the time figuring out which assembly was causing the problem, but that wouldn’t matter to you anyway. I simply unchecked Reuse types for now and everything started working; I deleted the service reference, re-added it, and the web.config was properly updated with the client endpoints and service bindings. Badda Boom. Service Model happiness.

If you don’t know how to get to this, you can either click the advanced button when adding the service reference or configure after it’s been added by clicking Configure Service Reference on the svcmap.


I hope this helps someone.

Happy coding,

Tom Hundley

One response to “WCF Service References not generating web.config client endpoints and bindings

What are your thoughts?

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.