【问题标题】:WCF Error 109: here was an error reading from the pipe. The pipe is closed on the client sideWCF 错误 109:这是从管道读取的错误。管道在客户端关闭
【发布时间】:2009-07-09 07:33:47
【问题描述】:

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

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 看起来像这样:

[服务合同] 公共接口 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));

输出是:

正在连接到身份验证服务... GetDeveloper OK : Asghar Panahy 从管道读取错误:De pipe is beëindigd。 (109, 0x6d)。

有人可以帮我解决这个问题吗? 阿斯加尔

【问题讨论】:

  • 你能把“De pipe is beëindigd”翻译成英文吗?另外,您是否应该将 WebGet 与 NetNamedPipeBinding 一起使用?
  • 我不知道,但是由于 WebGet 是用于 HTTP 的,请尝试将其删除,让我们看看会发生什么。
  • 类似的问题可能会有所帮助:stackoverflow.com/questions/4872352/…

标签: wcf wcf-client


【解决方案1】:

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

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

所以如果你应用 KnownTypeAttribute 它应该可以正常工作:

[DataContract]
[KnownType(Employee)]
public class Person
...

【讨论】:

    猜你喜欢
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-06
    • 1970-01-01
    • 1970-01-01
    • 2020-07-18
    相关资源
    最近更新 更多