WCF NamedPipe的CommunicationException - "该管道已结束。 (109,0x6d)QUOT。 [英] WCF NamedPipe CommunicationException - "The pipe has been ended. (109, 0x6d)."

查看:2865
本文介绍了WCF NamedPipe的CommunicationException - "该管道已结束。 (109,0x6d)QUOT。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我伴随编写Windows服务地位的工具。主机服务进程间通信的WCF命名管道终点。 状态通过命名管道,状态工具可以定期查询最新服务

I am writing a Windows Service with accompanying "status tool." The service hosts a WCF named pipe endpoint for inter-process communication. Through the named pipe, the status tool can periodically query the service for the latest "status."

在我的机器,我有多个IP地址;其中之一是一个本地网络与192.168.1.XX地址。另一种是公司网络,具有10.0.X.XX地址。 Windows服务收集在一个单一IP地址的UDP多播流量。

On my development machine, I have multiple IP Addresses; one of them is a "local" network with a 192.168.1.XX address. The other is the "corporate" network, with a 10.0.X.XX address. The Windows Service collects UDP multicast traffic on a single IP Address.

Windows服务了,到现在为止,工作得很好,只要它使用192.168.1.XX , 地址。它一贯正确报告状态给客户端。

The Windows Service has, until now, worked fine as long as it uses the "192.168.1.XX," address. It consistently reports the status correctly to the client.

当我切换到另一个,企业IP地址(10.0.X.XX),并重新启动该服务,我得到连续的CommunicationExceptions检索状态时:

As soon as I switched to the other, "corporate" IP Address (10.0.X.XX) and restarted the service, I get continuous "CommunicationExceptions" when retrieving the status:

"There was an error reading from the pipe: The pipe has been ended. (109, 0x6d)."

现在,我不认为UDP客户的要求IP地址应该有什么关系与命名管道接口的功能; !他们是应用程序的完全独立的部分。

Now, I wouldn't think that the UDP Client's 'claimed' IP address should have anything to do with the functionality of the Named-Pipe interface; they are completely separate pieces of the application!

下面是相关的WCF配置部分:

Here are the relevant WCF config sections:

//On the Client app:
string myNamedPipe = "net.pipe://127.0.0.1/MyNamedPipe";
ChannelFactory<IMyService> proxyFactory =
    new ChannelFactory<IMyService>(
        new NetNamedPipeBinding(),
        new EndpointAddress(myNamedPipe));


//On the Windows Service:
string myNamedPipe = "net.pipe://127.0.0.1/MyNamedPipe";
myService = new MyService(myCustomArgs);
serviceContractHost = new ServiceHost(myService );
serviceContractHost.AddServiceEndpoint(
    typeof(IMyService),
    new NetNamedPipeBinding(),
    myNamedPipe);

serviceContractHost.Open();



我不认为这是一个权限的问题 - 我运行在客户端与管理特权 - 但也许有一些特定领域的原因,这打破了

I wouldn't think this is a 'permissions' issue - I'm running the client with administrative privileges - but perhaps there's some domain-specific reason this broke?

推荐答案

IP地址是,事实证明,一个完整的红?鲱鱼。

The IP Address was, it turns out, a complete red herring.

的真正原因的例外是由WCF服务返回无效的枚举值。

The real reason for the exception was invalid Enum values being returned by the WCF service.

我的枚举是正是如此定义的:

My enum was defined thusly:

[DataContract]
public enum MyEnumValues : Byte
{
    [EnumMember]
    Enum1 = 0x10,
    [EnumMember]
    Enum2 = 0x20,
    [EnumMember]
    Enum3 = 0x30,
    [EnumMember]
    Enum4 = 0x40,
} 

它看起来很好的表面上。

It looks fine on the surface.

但是,到了底层服务报告的原始的状态是0字节值,并有为其投它没有相应的枚举值。

But the raw status reported by the underlying service was a Byte value of "0," and there was no corresponding Enum value for which to cast it.

有一次,我保证枚举值均有效,该工具照亮了像圣诞树一样。

Once I ensured that the Enum values were all valid, the tool lit up like a Christmas tree.

当有疑问,假设你的WCF数据是无效的。

When in doubt, assume your WCF data is invalid.

这篇关于WCF NamedPipe的CommunicationException - &QUOT;该管道已结束。 (109,0x6d)QUOT。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆