Domanda

I use .NET Framework 4.5. Created a new project WCF, which already has an example using CompositeType. Then created the console and ASP.NET MVC 4 applications. Further added service reference in both projects. Why in the project ASP.NET MVC 4 generated a empty class (in reference)? If remove the CompositeType in the service interface, then all is well. In the console application is no such problem and everything is created correctly.

È stato utile?

Soluzione

This is a known issue in VS 2012. Before a fix is available, you can use the following work around(s) to get your things working. Check out this blog.

http://blogs.msdn.com/b/praburaj/archive/2012/08/23/add-service-reference-adding-empty-reference-cs-in-mvc-4-projects-of-vs-2012.aspx

In VS 2012 MVC 4 projects, do you find an empty reference.cs file while adding a service reference to a WCF service using 'Add service reference' dialog?

Here is what you can do about it:

Check if your error tab shows some error like...

Warning 1 Custom tool warning: Cannot import wsdl:portType

Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter

Error: Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.

XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IService1']

If so, you can use the following work around(s):

  1. In add service reference dialog -> [Advanced ... ] -> Reuse types in referenced assemblies (Checked by default) -> Choose the non default 'Reuse types in specified referenced assemblies' radio -> Make sure you exclude Newtonsoft.Json.dll from the list. Try adding service reference now and see it succeeds.

  2. Alternatively you can remove reference of this Newtonsoft.Json.dll while generating proxy and add that back after proxy generation is complete.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top