If I use only simple methods in my WCF service, everything works fine. However, if I include the following method, a problem occurs:
[OperationContract]
public List<KeyValuePair<string, string>> GetAllAccounts()
{
return AccountBusiness.GetAllAccounts();
}
I get this error when referencing the service from another project:
Warning 5 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='NodeService'] C:inetpubwwwrootMyclientProjectService
ReferencesNodeServiceReference.svcmap 1 1 MyClientNode
If I remove the method above, recompile and update the reference, then it works fine. But when I add the above method, I consistently get this warning.
One suggestion I found was to uninstall Visual Studio 2012 and repair Visual Studio 2010. I don't want to do that.
Another suggested to uncheck "Reuse types in all referenced assemblys", but this messes up the method signatures and is not usable.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…