[英]Adding WCF service reference with additional DLL breaks
I have the following classes defined in an external assembly from a third-party vendor: 我在第三方供应商的外部程序集中定义了以下类:
namespace ThirdParty.Vendor.Code
{
[Serializable]
[XmlInclude(typeof(Test1Data))]
[XmlRoot(Namespace = "", IsNullable = false)]
public abstract class DeviceTestData
{
protected DeviceTestData();
}
[Serializable]
[XmlRoot(Namespace = "", IsNullable = false)]
public class TestData : DeviceTestData
{
public TestData();
public double DoubleValue { get; set; }
[XmlIgnore]
public bool DoubleValueSpecified { get; set; }
}
}
I've added this assembly as a reference to my WCF service called "TestService" so I can write service code that makes use of these types. 我已经添加了该程序集作为对我的WCF服务“ TestService”的引用,因此我可以编写使用这些类型的服务代码。 That all works perfectly. 一切都完美。
Now I have a second project to which I need to add a reference to TestService. 现在,我有第二个项目,需要在其中添加对TestService的引用。 Adding the reference works fine, but when I write code to use the referenced types and attempt to compile I get the following error: 添加引用工作正常,但是当我编写代码以使用引用的类型并尝试编译时,出现以下错误:
The type or namespace name 'TestData' could not be found (are you missing a using directive or an assembly reference?)
So I added the vendor's DLL as a reference in the second project and a directive to use the namespace ThirdParty.Vendor.Code, but now I get: 因此,我在第二个项目中添加了供应商的DLL作为参考,并添加了使用命名空间ThirdParty.Vendor.Code的指令,但是现在我得到了:
Cannot implicitly convert type 'ThirdParty.Vendor.Code.TestData' to 'ServiceReference.DeviceTestData'
It seems that without the reference to the third-party DLL, the required classes don't get generated, but if I add the reference, they get referenced twice somehow. 似乎,如果没有对第三方DLL的引用,则不会生成所需的类,但是如果我添加了引用,则它们会以某种方式被引用两次。 WTF? WTF?
Anyone got any suggestions for how to fix/work around this? 任何人都有关于如何解决/解决此问题的任何建议?
生成服务引用时,请确保您已拥有已引用数据协定的程序集,然后选择“在被引用程序集中重用类型”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.