开发者

Internal communication between a service and multiple user applications WCF C#

开发者 https://www.devze.com 2023-04-03 17:41 出处:网络
I\'m currently working on a project in c# where I have a service running as LocalSystem, and a user application (tray app) running for each logged on user.

I'm currently working on a project in c# where I have a service running as LocalSystem, and a user application (tray app) running for each logged on user.

I need to have communications between the two. Initially I've set up an endpoint using NetTcpBinding on the service for the clients to connect to and supply their username. Thereafter the clients each set up an endpoint themselves as such; net.tcp://localhost:5001/UserApp/'username', with port sharing enabled. The service can then connect to that endpoint, knowing the username.

Though, when trying to get the program to work well with UAC I ran into some issues. Port sharing with UAC enabled requires the user to be registred in <'allowAccounts> of SMSvcHost.exe.config, and even though I've added the user, I still get the following errror when trying to register the endpoint;

The service endpoint failed to listen on the URI 'net.tcp://localhost:5001/UserApp/myuser' because access was denied. Verify that the current user is granted access in the appropriate allowAccounts section of SMSvcHost.exe.config开发者_如何学运维.

I've also tried switching to NetNamedPipeBinding, which works well when hosting the user application. But when using this binding the service can not access the endpoints opened by the clients.

So, basically I need a way for a single service to provide an endpoint for multiple user applications on the same machine, and the service to be able to connect to and send event updates to multiple user applications.

Any suggestions?


in this case I would think about using callback channels instead of opening new services on the client (ok - it's almost the same but it fit nices into the WCF framework and setting). You can read about this here: What you need to know about One-Way Calls, Callbacks, And Events


You may want to also look Duplex services, in particular the 'wsDualHttpBinding'. It is designed to do just want you are asking... to allow both the service and client to send messages independently to each other.

http://msdn.microsoft.com/en-us/library/ms731064.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消