Manoj Dwivedi
Manoj Dwivedi

Reputation: 95

No endpoint of WCF based Named Pipe service for specific application

I am facing a strange issue with windows service communicating to a windows form (Notification Tray) application using WCF based Named Pipe Endpoint.(.Net Framework 4.0)

Once the setup is installed, the service properly sends the message to my winform(notification tray) application and it works as expected.

But once I restart the machine. The service is unable to find the Namedpipe endpoint. I tried sending message by creating another application from VS 2010 and it was able to send the message to my windows form (Notification Tray) application.

The exception that the windows service throws is

 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).

Upvotes: 1

Views: 999

Answers (1)

Manoj Dwivedi
Manoj Dwivedi

Reputation: 95

I would like to think that the issue pertained to the security context. The service which ran under the security context "SYSTEM" could find the "Named Pipe" serivce's Endpoint just after the setup installation, as the setup elevated its privileges with a UAC Pop-up, which consequently ran the Windows service and the WinForm(Namedpipe Host) application under the same security context, and thus the endpoint was found. Upon restart, the service stayed under the same security context although the Winform Application was under the logged-in users security context, which caused the "NamedPipe" being hosted in a separate security context from the service. And the service tried to find the endpoint falling in its security context which it wasn't this time. Hence the "Endpoint Not Found" Exception.

Upvotes: 2

Related Questions