2

I have references to two different WCF services in a project. I updated the reference for one of the services, and now no code is generated for it. The references.cs file just has the "this is genrated code" comment at the top. Updating that same service in other projects and updating the other service both work fine. It's only that one service reference in this one project that's causing the problem, and I'm getting no information from Visual Studio (it just says it failed to generate code and I should look at the other errors, which provide no information).

If I uncheck the "reuse types in referenced assemblies", code is generated, but I don't want to have this one project be different from the others. I'd like to solve the problem. Re-checking the reuse type option produces an empty references.cs file, again. The collection type doesn't seem to matter, either.

How can I diagnose and solve this problem?

Update:

It seems I was mistaken. Updating the service reference does seem to break the generation in other projects as well. I did also notice these warnings, as well:

Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: ISerializable type with data contract name 'Exception' in namespace 'http://schemas.datacontract.org/2004/07/System' cannot be imported. The data contract namespace cannot be customized for ISerializable types and the generated namespace 'TheDefaultNamespaceOfTheProject.ServiceReferenceName' does not match the required CLR namespace 'System'. Check if the required namespace has been mapped to a different data contract namespace and consider mapping it explicitly using the namespaces collection.

Obviously I changed the namespace there, but it seems like it's trying to map System.Exception to ThatNamespace.Exception? Why would it do that, and how can I correct it? I think this is the key to the whole thing.

Mike Pateras
  • 14,715
  • 30
  • 97
  • 137
  • Try using the command-line svcutil.exe program. It has the advantage that it outputs error messages to the console. – John Saunders Jan 01 '11 at 20:54
  • It ran successfully and generated code. Was this for diagnostic purposes, or is the idea to use it instead of the service contract utility in Visual Studio? – Mike Pateras Jan 02 '11 at 03:23

1 Answers1

0

I had a similar error in a Silverlight application making WCF calls. I created a WCF method that passed an Exception object as a parameter. It turns out that Exception objects are not serializable in Silverlight because:

http://blogs.msdn.com/b/suwatch/archive/2009/01/21/wcf-silverlight-exception-and-serialization.aspx

Here's the relevant excerpt:

WCF’s DataContractSerializer serialize s Exception class via ISerializable (Exception in .Net Framework implements ISerializable). However, in Silverlight, there is no ISerializable interface. Therefore, Serialization information of Exception transferred over the wire will not be set into the Exception class. This does not only apply to Exception but also any types implementing ISerializable on the .Net Framework serialized to Silverlight.

John Gilmer
  • 831
  • 1
  • 11
  • 18