没有针对特定应用程序的基于WCF的命名管道服务的端点

时间:2013-01-03 14:13:27

标签: .net wcf windows-services

我面临一个奇怪的问题,Windows服务使用基于WCF的命名管道端点与Windows窗体(通知托盘)应用程序进行通信。(。Net Framework 4.0)

安装完设置后,服务会将消息正确发送到我的winform(通知托盘)应用程序,并按预期工作。

但是一旦我重新启动机器。该服务无法找到Namedpipe端点。我尝试通过从VS 2010创建另一个应用程序来发送消息,并且能够将消息发送到我的Windows窗体(通知托盘)应用程序。

Windows服务抛出的异常是

 There was no endpoint listening at net.pipe://localhost/Pipe/Pipe1 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Error innerException : System.IO.PipeException: The pipe endpoint 'net.pipe://localhost/Pipe/Pipe1' could not be found on your local machine.
Error stackStrace : Server stack trace: at System.ServiceModel.Channels.PipeConnectionInitiator.GetPipeName(Uri uri, IPipeTransportFactorySettings transportFactorySettings) at System.ServiceModel.Channels.NamedPipeConnectionPoolRegistry.NamedPipeConnectionPool.GetPoolKey(EndpointAddress address, Uri via) at System.ServiceModel.Channels.CommunicationPool`2.TakeConnection(EndpointAddress address, Uri via, TimeSpan timeout, TKey& key) at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NamedPipe.Communication.IPipeService.PipeIn(String data) at NamedPipe.Sender.SendMessage(String messages, String PipeName) at NamedPipe.Sender.SendMessage(String messages).

1 个答案:

答案 0 :(得分:2)

我想这个问题与安全背景有关。在安装上下文“SYSTEM”下运行的服务可以在安装程序安装之后找到“命名管道”服务器的端点,因为安装程序通过UAC弹出窗口提升其权限,从而运行Windows服务和WinForm(< strong> Namedpipe Host )应用程序在相同的安全上下文下,因此找到了端点。重新启动后,虽然Winform Application位于登录用户安全上下文中,但该服务仍保留在相同的安全上下文中,这导致“NamedPipe”托管在与服务不同的安全上下文中。该服务试图找到端点落在其安全上下文中,而这次不是。因此“端点未找到”例外。