Hi
I require a Windows Service to make WCF calls to a service hosted in a WinForms application.
Unfortunately when attempting the call the Windows Service fails to discover the Endpoint.
I have tried changing the Log On properties for the Windows Service to allow interaction with the desktop, however this did not help.
I have used the exact same hosting code (as used by the WinForms app) in a Console application and the Windows Service finds the Endpoint no problem.
Any help would be much appreciated...
Code to host service in WinForms app.
_myServiceHost = new ServiceHost(typeof(MyService);
_myServiceHost.AddServiceEndpoint
(
typeof (IMyService),
new NetNamedPipeBinding(),
@"net.pipe://localhost/MyService"
);
_myServiceHost.Open();
Code from the client proxy...
_serviceFactory = new ChannelFactory<IMyService>
(
new NetNamedPipeBinding(),
"net.pipe://localhost/MyService"
);
...
IMyService clientProxy = _serviceFactory.CreateChannel();
clientProxy.SomeMethod();
This problem does appear to be to do with the security context in which windows services run that is preventing the Endpoint hosted by the WinForms app from being visible to the service but not vica versa.
UPDATE:
I tried changing the binding from NetNamedPipeBinding to NetTcpBinding and it seems to work fine with this type of binding.