WCF错误109:从管道读取时出错。管道在客户端关闭
我的客户端应用程序出现以下错误WCF错误109:从管道读取时出错。管道在客户端关闭,wcf,wcf-client,Wcf,Wcf Client,我的客户端应用程序出现以下错误 There was an error reading from the pipe: De pipe is beëindigd. (109,0x6d). 使用我的OperationContract的特定实现时。以下是一个切中要害的示例。 我的数据合同如下: [DataContract] public class Person { [DataMember] public string FirstName { get; set; } [Data
There was an error reading from the pipe: De pipe is beëindigd. (109,0x6d).
使用我的OperationContract的特定实现时。以下是一个切中要害的示例。
我的数据合同如下:
[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; }
}
我的服务合同如下所示:
[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; }
}
[服务合同]
公共接口身份验证
{
}
我像以下类一样实现此服务:
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;
}
}
注意:两个方法都返回相同的类型,只有一个方法实例化一个人并返回它,而第二个方法实例化一个员工,该员工也是一个人
当我从客户端调用它时,我在服务器上没有得到任何错误,但在客户端:
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));
Console.WriteLine(“连接到身份验证服务…”);
NetNamedPipeBinding myBinding=新的NetNamedPipeBinding(“Authentication.Endpoint”);
EndpointAddress myEndpoint=新的EndpointAddress(“网络地址”)。pipe://localhost/authentication"); ;
var myChannelFactory=新的ChannelFactory(myBinding,myEndpoint);
IAAuthentication proxy=myChannelFactory.CreateChannel();
Person=proxy.GetDeveloper();
WriteLine(String.Format(“GetDeveloper OK:{0}{1}”,person.FirstName,person.LastName));
person=proxy.GetArchitect();
WriteLine(String.Format(“GetArchitect OK:{0}{1}”,person.FirstName,person.LastName));
输出为:
正在连接到身份验证服务。。。
GetDeveloper OK:Asghar Panahy
从管道读取时出错:De pipe为beëindigd。(109,0x6d)
谁能帮我一下吗?
Asghar我知道这个问题有点老了,但我还是可以帮助别人。现在命名管道绑定也有同样的问题(得到相同的错误) 这里的问题是Employee派生类的返回。 这是一个很好的解释 因此,如果您应用KnownTypeAttribute,它应该可以正常工作:
[DataContract]
[KnownType(Employee)]
public class Person
...
你能把“De pipe is beëindigd”翻译成英语吗?另外,您是否应该将WebGet与NetNamedPipeBinding一起使用?我不知道,但由于WebGet是用于HTTP的,请尝试将其删除,让我们看看会发生什么。这里类似的问题可能会有所帮助: