我在我的客户端应用程序上收到以下错误
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] public interface 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并返回它,而第二个方法实现一个Personee也是一个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));
输出是:
连接到验证服务... GetDeveloper OK:Asghar Panahy从管道读取错误:De pipeisëindigd . (109,0x6d) .
有人可以帮我这个吗?阿斯加尔
1 回答
我知道这个问题有点旧,但我可能还会帮助别人 . 我现在遇到与命名管道绑定相同的问题(获得相同的错误) .
这里的问题是返回Employee派生类 . 有一个很好的解释here
因此,如果应用KnownTypeAttribute,它应该可以正常工作: