.net 特定应用程序没有基于WCF的命名管道服务的终结点

.net 特定应用程序没有基于WCF的命名管道服务的终结点,.net,wcf,windows-services,.net,Wcf,Windows Services,我在使用基于WCF的命名管道端点与windows窗体(通知托盘)应用程序通信时遇到了一个奇怪的问题。(.Net Framework 4.0) 安装安装程序后,服务会将消息正确发送到我的winform(通知托盘)应用程序,并按预期工作 但一旦我重启机器。服务找不到Namedpipe终结点。我尝试从VS2010创建另一个应用程序来发送消息,它能够将消息发送到我的windows窗体(通知托盘)应用程序 windows服务引发的异常是 There was no endpoint listening a

我在使用基于WCF的命名管道端点与windows窗体(通知托盘)应用程序通信时遇到了一个奇怪的问题。(.Net Framework 4.0)

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

但一旦我重启机器。服务找不到Namedpipe终结点。我尝试从VS2010创建另一个应用程序来发送消息,它能够将消息发送到我的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).

我想,这个问题与安全背景有关。在安全上下文“系统”下运行的服务可能会在安装程序安装后立即找到“命名管道”服务的端点,因为安装程序通过UAC弹出窗口提升了其权限,从而在相同的安全上下文下运行Windows服务和WinForm(Namedpipe Host)应用程序,这样就找到了终点。重新启动时,尽管Winform应用程序处于登录用户安全上下文中,但服务仍处于相同的安全上下文中,这导致“NamedPipe”托管在与服务不同的安全上下文中。该服务试图发现端点处于其安全上下文中,但这次没有。因此出现“未找到端点”异常。

您的winform应用程序正在运行吗?是的,我的winform应用程序正在运行,它也显示在托盘图标中。当从控制台应用程序或其他应用程序命中指定管道时(当计算机重新启动时,即windows服务无法通信时),它还显示通知气球。