简体   繁体   English

JSON.NET(NewtonSoft.dll)更改了我的代理类,同时更新了我的wcf服务参考

[英]JSON.NET(NewtonSoft.dll) changed my proxy class while updating my wcf service reference

I am working on HealthCare project. 我正在进行HealthCare项目。 I have been given task to convert JSON format to HL7 format. 我已获得将JSON格式转换为HL7格式的任务。 To make it happen, I imported Newtonsoft.dll to my project. 为此,我将Newtonsoft.dll导入到我的项目中。 After adding the reference to my project, while updating the WCF service reference, I found my whole proxy class was changed because of the added Newtonsoft reference. 在将引用添加到我的项目后,在更新WCF服务引用时,我发现由于添加了Newtonsoft引用,整个代理类都发生了更改。

It comes up with more than 200 syntax issues in my WPF application. 我的WPF应用程序中涉及200多个语法问题。 Most of the issues related to data type conversion, issues like: 大多数问题与数据类型转换有关,例如:

Cannot implicitly convert type 'System.Xml.XmlElement' to 'System.Xml.Linq.XElement' 无法将类型'System.Xml.XmlElement'隐式转换为'System.Xml.Linq.XElement'

Cannot implicitly convert type 'string[]' to 'System.Collections.Generic.List' 无法将类型'string []'隐式转换为'System.Collections.Generic.List'

If I remove the Newtonsoft DLL and update the WCF service again, everything works perfectly. 如果删除Newtonsoft DLL并再次更新WCF服务,则一切正常。

You have a type name conflict somewhere in your code. 您的代码中某处存在类型名称冲突。 The Newtonsoft library contains a type with the same name as another type used by your source code. Newtonsoft库包含与源代码使用的另一种名称相同的名称。 When you add the Newtonsoft library, your code gets confused over which type to use. 当您添加Newtonsoft库时,您的代码会混淆使用哪种类型。

You can fix this by using the fully qualified type name (include the namespace). 您可以使用完全限定的类型名称(包括名称空间)来解决此问题。

eg If both libraries contain a class called XmlThingy: 例如,如果两个库都包含一个名为XmlThingy的类:

change 更改

var myXmlThing = new XmlThingy();

to

var myXmlThing = new ALibrary.Xml.XmlThingy();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM