17,740
社区成员
发帖
与我相关
我的任务
分享
[ServiceContract]
public interface ITestService1
{
[OperationContract]
TestCustomData GetVal1();
}
[ServiceContract]
public interface ITestService2
{
[OperationContract]
TestCustomData GetVal2();
}
public class TestService1 : ITestService1
{
public TestCustomData GetVal1()
{
return new TestCustomData() { Name = "x1", Age = 12 };
}
}
public class TestService2 : ITestService2
{
public TestCustomData GetVal2()
{
return new TestCustomData() { Name = "x2", Age = 24 };
}
}
[DataContract(Name = "TcData", Namespace = "http://www.cnblogs.com")]
public class TestCustomData
{
public string Name { get; set; }
public int Age { get; set; }
}
客户端我添加两个服务引用, 配置“始终生成消息约定”,分别是 TestService1Reference 和 TestService2Reference ,生成客户端代理, 在代码中定义 TcData data; 同样,会报错 CS0104, “TcData”是“TestService1Reference.TcData”和“TestService2Reference.TcData”之间的不明确的引用