Service reference not generating client types

You may have selected Reuse types in specified reference assemblies but not chosen the very important mscorlib library.

First click ‘Show All Files’ at the top of your Solution Explorer so you can expand out the service reference.

enter image description here

  • Find the Reference.cs file and open it.
  • Search for ClientBase in the source code to make sure you really haven’t generated a client with a name you weren’t expecting. If you find it then that’s the name of your service client.

enter image description here

If nothing matches then right click the service reference and choose Configure Service Reference.

The important one is mscorlib which is required to properly generate the client. I like to select System.Xml.Linq also to get nice Linq classes like XElement and not XmlElement.

enter image description here


Still stuck?

  • Tip: I always prefer to create a dedicated DLL just for the service reference. It can help if you need to wipe it out and start over, and it avoids certain chicken-and-egg compile problems once in a while.

  • If you end up with half a References.cs file you may be ‘reusing a referenced type’ that is not compatible with your data contract. i.e. you’ve added data members on the server side, or changed the signature of an existing member such as making a value type optional.

  • First, realize that SVCUTIL will quite happily generate an incomplete output file even if it has problems, and when running from Visual Studio you don’t get the log file. Keep an eye in Explorer for the expected size and compare it to your ‘last known good’ size.

  • Try to run SVCUTIL.EXE directly from a batch file (remember to save this file for next time)

  • This is easiest to do in a Visual Studio Command prompt

  • Sample command is as follows, note the reference parameter to the DLL that you are referencing types from.

    svcutil.exe http://dev.example.com/SSWPF.Web/Services/SS.svc /reference:bin\debug\RRStore.Sys.DLL

Detail: An exception was thrown while running a WSDL import extension:

System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Referenced type ‘SS.Sys.ShippingRateInfo, RRStore.Sys, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’
with data contract name ‘ShippingRateInfo’ in namespace
http://schemas.datacontract.org/2004/07/SS.Sys‘ cannot be
used since it does not match imported DataContract. Need to exclude
this type from referenced types.
XPath to Error Source: //wsdl:definitions[@targetNamespace=”http://tempuri.org/“]/wsdl:portType[@name=”ISSWCF”]

Fortunately the answer here was simple, my type ShippingRateInfo had changed and I hadn’t updated it. Once I copied this type over from the server everything compiled just fine (I chose to revert back to VS tool).

Leave a Comment