Silverlight: Update service reference for a WCF service generating empty class

My Visual Studio sometimes goes angry. I had a Silverlight 2 – WCF – LINQToSQL application that I recently converted to Silverlight 3. I noticed that sometimes the Update Service Reference does not function properly and instead blanks out the generated reference.cs. It broke once again today and I decided to blog it. Here are the contents of Error window when such abnormal activity happens:

Custom tool error: Failed to generate code for the service reference '..'.  Please check other error and warning messages for details.

The warning tab may have many warnings, some of which are:

Custom tool warning: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Custom tool warning: The type 'System.Collections.ObjectModel.ObservableCollection`1' could not be found.  Ensure that the assembly containing the type is referenced.  If the assembly is part of the current development project, ensure that the project has been built.

Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Exception has been thrown by the target of an invocation.
XPath to Error Source: //wsdl:definitions[@targetNamespace='']/wsdl:portType[@name=..]

Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='..']/wsdl:binding[@name='..']

Custom tool warning: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.

Ok. Looks like something is wrong with the Observable Collection reference. This was further confirmed when I brought up the service configuration window (by right clicking the WCF service and selecting Configure Service Reference), and noticed that the ObservableCollection collection type has been replaced by { Custom } :

service-reference-incorrect

For comparison, here’s the normal screenshot for this window:

service-reference-correct

To get rid of this and regenerate service proxy properly, I had to remove the Reuse types in all referenced assemblies (or at least System assembly).

So, if such behavior ever happen to you, try to update the service reference after unchecking the reuse types checkbox. Once done, you can recheck the option and update your service reference again.

Advertisements

20 Responses to “Silverlight: Update service reference for a WCF service generating empty class”

  1. DotNetShoutout Says:

    Silverlight: Update service reference for a WCF service generting empty class « Mehroz’s Experiments…

    Thank you for submitting this cool story – Trackback from DotNetShoutout…

  2. DotNetBurner - Silverlight Says:

    Silverlight: Update service reference for a WCF service generting empty class « Mehroz’s Experiments…

    DotNetBurner – burning hot .NET content…

  3. FretNoize Says:

    Here is what helped me:

    http://blogs.infosupport.com/blogs/raimondb/archive/2008/02/14/Unable-to-generate-a-WCF-proxy-using-svcutil-but-retreiving-the-wsdl-works_3F00_.aspx

    Basically, give write rights to C:\Windows\Temp to the user under which the AppPool runs (or, to be sure this error does not happen again, give everybody write rights…)

  4. Syed Mehroz Alam Says:

    That’s a great find, FretNoize. I will verify this and update my post once I get the error again.

  5. Sankar Says:

    I am getting this error also
    The given key was not present in the dictionary.
    And two warning
    Warning 1 Custom tool warning: Endpoint ‘WSHttpBinding_IService1’ at address

    ‘http://localhost:1787/Service1.svc’ is not compatible with Silverlight 3. Skipping…

    D:\SilverlightProjects\SilverlightDemo\SilverlightDemo\Service

    References\ServiceReference1\Reference.svcmap

    Warning 2 Custom tool warning: No endpoints compatible with Silverlight 3 were found.

    The generated client class will not be usable unless endpoint information is provided via

    the constructor.

  6. Syed Mehroz Alam Says:

    Hi Sankar,

    Are you using wsHttpBinding for your service? I believe it isn’t supported for Silverlight yet. You may need to tweak your web.config to use basicHttpBinding or a custom binary binding. Have a look at this post: http://johnpapa.net/silverlight/wcf-binary-bindings-in-silverlight-3/

  7. silverlight user Says:

    Nice article …. helped me a lot

  8. Martyn Says:

    When I get this problem, the only way to resolve it is to close down studio, reopen and update will work again.

  9. Florin Says:

    superb

  10. bashadavinci Says:

    Thanks a ton
    this worked for me.
    may God give you strength to help us in this way.

  11. jhpajiri Says:

    Thanks for the short and well explain article, you make my day happy.

  12. ramkrishn saini Says:

    Thanks man. Its work nice. I just run my project into VS2012 that developed into VS2010 SP1 and got this error but after
    unchecking the reuse types checkbox It resolved.

  13. Martin Says:

    thank you very much, this spared me a lot of time bashing my head in the wall … 🙂

  14. venkata Says:

    Thank You Very much. It’s really grat. I have searched a lot for this. In my case Proxy is creating but not showing intellisense in coding.

  15. Rameez Ahmed Sayad Says:

    Nice article !!! Although in my case it was pretty straight forward the client address was incorrect. Still it gave some other error. From this article it clicked my mind to check ‘Configure Service Reference’.

  16. Rukshan Unantenna Says:

    Thanks…Did work for me.

  17. Fix Soapui Wcf Error Importing Wsdl Windows XP, Vista, 7, 8 [Solved] Says:

    […] Silverlight: Update service reference for a WCF service … – Oct 29, 2009 · 16 Responses to “Silverlight: Update service reference for a WCF service generating empty class”… […]

  18. getlink.at Says:

    Now I am going away to do my breakfast, when having my breakfast coming over again to read further news.

  19. Look At this Says:

    Thank you, I have just been looking for info approximately this topic for ages and yours is the best I’ve discovered so far.
    However, what about the bottom line? Are you positive about the supply?

  20. Dotnet Shoutout - uinfo45.net Says:

    […] Silverlight: update service reference for a wcf service […]


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

%d bloggers like this: