简体   繁体   中英

Communicate between two .Net Applications running on terminal services

I have an inhouse ERP developed in .NET and in the process of developing an Outlook Add On. I need to send a message from my outlook add on to my already running instance of ERP to open a certain file. There are many instances of the ERP on the same server (1 per user using terminal services) and I cant use WCF as a result.

I want the outlook add on to send a message to the instance of my ERP running on the user session. Is that possible with WCF? Or what other methods can I use?

You can use the Window Terminal Services api to get a session id to include as part of your uri. eg, [System.Runtime.InteropServices.DllImport("wtsapi32.dll")] internal static extern bool WTSQuerySessionInformation( System.IntPtr hServer, int sessionId, WTS_INFO_CLASS wtsInfoClass, out System.IntPtr ppBuffer, out uint pBytesReturned);

hServer = IntPtr.Zero will use the local server (normally what is wanted unless you're managing client sessions remotely) sessionId can be passed in as -1 (WTS_CURRENT_SESSION) to get the current session details if you're calling from inside the session.

I am trying to do exactly the same (single service, 1 client per session) but I have run into a problem whereby the named pipe listener appears to be getting closed when the client session is disconnected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM