我的客户端应用程序出现以下错误
There was an error reading from the pipe: De pipe is beëindigd. (109,0x6d).
使用我的 OperationContract 的特定实现时。以下是切入要点的示例。我的 DataContracts 是这样的:
[DataContract]
public class Person
{
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
}
[DataContract]
public class Employee : Person
{
[DataMember]
public string Function { get; set; }
}
我的 ServiceContract 看起来像这样:
[ServiceContract] 公共接口 IAuthentication {
[OperationContract]
[WebGet]
Person GetDeveloper();
[OperationContract]
[WebGet]
Person GetArchitect();
}
我像下面的类一样实现这个服务:
public class Authentication : IAuthentication
{
public Person GetDeveloper()
{
Person architect = new Person()
{
FirstName = "Asghar",
LastName = "Panahy"
};
return architect;
}
public Person GetArchitect()
{
Employee architect = new Employee()
{
FirstName = "Asghar",
LastName = "Panahy",
Function = "Architect"
};
return architect;
}
}
注意:两种方法都返回相同的类型,只有一种方法实例化了一个 Person 并返回它,而第二种方法实例化了一个 Employee 也是一个 Person。
当我从客户端调用它时,我在服务器上没有收到任何错误,但在客户端:
Console.WriteLine(" Connecting to Authenticate service... ");
NetNamedPipeBinding myBinding = new NetNamedPipeBinding("Authentication.Endpoint"); ;
EndpointAddress myEndpoint = new EndpointAddress("net.pipe://localhost/authentication"); ;
var myChannelFactory = new ChannelFactory<IAuthentication>(myBinding, myEndpoint);
IAuthentication proxy = myChannelFactory.CreateChannel();
Person person = proxy.GetDeveloper();
Console.WriteLine(String.Format("GetDeveloper OK : {0} {1} ", person.FirstName, person.LastName));
person = proxy.GetArchitect();
Console.WriteLine(String.Format("GetArchitect OK : {0} {1} ", person.FirstName, person.LastName));
输出是:
正在连接到 Authenticate 服务... GetDeveloper OK : Asghar Panahy 从管道读取错误:De pipe is beëindigd。(109, 0x6d)。
有人可以帮我吗?阿斯加尔