Getting “Recursive collection data contract” when referencing a WCF service with a slightly complex method

前端 未结 2 1241
日久生厌
日久生厌 2020-12-06 19:30

If I use only simple methods in my WCF service, everything works fine. However, if I include the following method, a problem occurs:

[OperationContract]
publ         


        
相关标签:
2条回答
  • 2020-12-06 19:54

    The NewtonSoft.Json library that is installed on the Server is not the same one that is installed on the client from NuGet. This is why the service reference is unable to reuse it.

    In this case just click on 'Reuse types in specified referenced assemblies', check everything off but the Newtonsoft.Json assembly and re-generate.

    The Service Reference will now generate without errors.

    0 讨论(0)
  • 2020-12-06 20:11

    As it turned out, the error was caused by the fact that I had a Microsoft Web API package installed from NuGet, which included Json.NET. After uninstalling this, it works fine.

    This may be the answer for you - if not, look at which other packages you have installed (that you don't need) and remove them.

    0 讨论(0)
提交回复
热议问题