1

更新 20121214 咨询冲突服务的开发者,他们使用net.pipe://echonet作为服务地址,并使用DuplexChannelFactory。为什么它会阻塞我的管道?


问题:

我有一个非常简单的 WCF 应用程序。Service 和 Client 通过 NetNamedPipe 通信。但奇怪的是,有些机器可能是因为其他软件的原因,导致ChannelFactory开始调用Service,抛出异常:System.ServiceModel.ProtocolException。

我怎么知道哪个应用程序捕获了我的 WCF 消息,以及我应该如何避免这个问题。

这是例外:

System.ServiceModel.ProtocolException: The requested upgrade is not supported by 'net.pipe://localhost/xxxx/xxxx'. This could be due to mismatched bindings (for example security enabled on the client and not on the server)

Server stack trace: 
  System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
  System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
  System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
  System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
  System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
  System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
  System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
  System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
  System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
  System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
  System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
  System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
  System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
  xxx.xxxxx.Communication.Contracts.IxxxComClientService.Register(ClientInfo clientInfo)
  xxx.xxxxx.Communication.xxxComClient.ActionClientRegisterOnlineClientInfo(IxxxComClientService channel)
  xxx.xxxxx.Communication.xxxComClient.ActionReceivedClientOnline(EndpointAddress endpoint)

这是我的代码'

- - - - - - - - - - - - - - 服务 - - - - - - - - - - - ---------

 using (var host = new ServiceHost(typeof(StringReverser), new[] { new Uri("net.pipe://localhost") }))
 {
     host.AddServiceEndpoint(typeof(IStringReverser), new NetNamedPipeBinding(), "PipeReverse");
     host.Open();

     Console.WriteLine("Service is available. Press <ENTER> to exit.");
     Console.ReadLine();

     host.Close();
  }

- - - - - - - - - - - - - 客户 - - - - - - - - - - - - ----------

var pipeFactory = new ChannelFactory<IStringReverser>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/PipeReverse"));
Console.WriteLine("pipeFactory Created. Press <Exit> to exit");
var pipeProxy = pipeFactory.CreateChannel();
Console.WriteLine("pipeProxy Created.");

while (true)
{
   var str = Console.ReadLine();
   Console.WriteLine("pipe: " + pipeProxy.ReverseString(str));
}
4

1 回答 1

0
  • b1。该服务是windowsservice上的主机,以管理员身份运行
  • b2。服务,设置 net.pipe://echonet 作为他的地址
  • b3。我的服务是自托管,以本地用户身份运行

windowsservice > localuser 因此,namedpipe 将重定向到该服务。

  • s1。停止服务
  • s2。更改我的服务主机,让它托管在 windowsservice 上。
于 2012-12-14T08:02:59.617 回答