WCF错误109:这是从管道读取错误。管道在客户端关闭

时间:2009-07-09 07:33:47

标签: wcf wcf-client

我的客户端应用程序出现以下错误

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并返回它,而第二个方法实现一个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 个答案:

答案 0 :(得分:1)

我知道这个问题有点旧,但我仍然可以帮助别人。我现在遇到了与命名管道绑定相同的问题(得到相同的错误)。

这里的问题是返回Employee派生类。 有一个很好的解释here

因此,如果应用KnownTypeAttribute:

,它应该可以正常工作
[DataContract]
[KnownType(Employee)]
public class Person
...
相关问题