Silverlight & WCF Service Reference Weirdness: SOLVED: Custom tool error: Failed to generate code for the service reference ‘ServiceReference1’. Please check other error and warning messages for details.

Added a service reference as usual.

image

Got a single error message that referenced “other errors and warnings”. No other errors and warnings :

image

No code was generated in my service reference.

image

Unchecked “Reuse types in referenced assemblies” check box.

image

Service reference code gets generated!

image

But why did this happen? I have another project referencing the same service with the “Reuse types in referenced assemblies” check box checked with no problem. Just out of the blue this project stops working?

9 thoughts on “Silverlight & WCF Service Reference Weirdness: SOLVED: Custom tool error: Failed to generate code for the service reference ‘ServiceReference1’. Please check other error and warning messages for details.

  1. First of all, it’s not correct that you didn’t get any other warnngs. It’s clearly visible in your screenshot that you got 7 warnings, but you have deliberately chosen not to show these. Just click on the tab and they will appear.

    That aside, I’m encountering the same problem, or symptom at least. Without seeing your actual warning, it’s hard to say.

    In “Project1”, I have a service reference to “Service1”.
    In “Project2”, I have the same service reference to “Service1”.
    In “Project2”, there’s a project reference to “Project1”.

    Before upgrading to Silverlight 4, I was able to perform “Update Service Reference” for both of these individually.
    Now, though, I can still update the service refs in the “innermost” “Project1”.
    Whereas in “Project2”, I get an empty “Reference.cs” file and the same error you got.
    I also get a whole bunch of warnings, where the most important one is this (slightly anonymized):

    Warning 2 Custom tool warning: Cannot import wsdl:portType
    Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
    Error: The list of referenced types contains more than one type with data contract name ‘ResponseBase’ in namespace ‘http://schemas.datacontract.org/2004/07/XXX’. Verify the list of referenced assemblies for type reuse in the ‘Advanced’ dialog in ‘Add Service Reference’. You need to exclude all but one of the following types. Only matching types can be valid references:
    “XXXProxy.ResponseBase, XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”
    “XXXProxy.ResponseBase, XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”
    XPath to Error Source: //wsdl:definitions[@targetNamespace=”]/wsdl:portType[@name=’XXX’] C:XXXService ReferencesXXXProxyReference.svcmap 1 1 XXX

    What this basically is saying, is that when I update the service ref in the “outermost” “Project2”, it tries to create a class (“ResponseBase” in this case), which it thinks it has got already (in the same namespace).
    The solution to this is to go into “Configure Service Reference…”, keep the checkbox in “Reuse types in referenced assemblies”, but switch from “Reuse types in all referenced assemblies” to “Reuse types in specified referenced assemblies:”, and then select all of the ones in the list, EXCEPT the project reference to “Project1” in this case.

    Don’t know if this makes any sense, but it seems to be to be a breaking change between Silverlight 3 and 4.

    What’s even more strange about this is that within “Project1”, there are two service refs against services which in this case both exposes the same base class “ResponseBase”. Why doesn’t it complain about these two proxy classes in the same manner?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s