0

I'm creating a server (PHP/JS) application which is communicating with a client application (C#) over Websockets (WS). The C# application is listening to port 4001 and the server application will create for each request (in javascript) a websocket to the C# application.

In the server application it is possible for the end-user to create a new e-mail, which will be send over the websocket so the client application creates the e-mail in Outlook (using Microsoft.Office.Interop.Outlook). So far so good, everything is working fine.

I need to run this client application for each user on the remote desktop envoirment, because it's using the Microsoft.Office.Interop.Outlook libary. This is impossible, because there can only be 1 instance of the application listening to port 4001. I read on various sources that it is impossible to use Microsoft.Office.Interop.Outlook as a C# service.

My question is, how can I achieve that there is only one active instance of the client application on the server side, which can use the Microsoft.Office.Interop.Outlook libary off the current user.

S.Pols
  • 3,414
  • 2
  • 21
  • 42
  • A few questions: 1. Do you really need to use `Interop.Outlook` for your mail processing? 2. You say that `client application creates the e-mail in Outlook`, but then you start talking about `there can only be 1 instance of the application listening to port 4001` and `it is impossible to use Microsoft.Office.Interop.Outlook as a C# service` that contradicts the `client application creates the e-mail in Outlook` part. So who uses Interop? Client, or server? Or do you mean that your client is another service? – Eugene Podskal Jan 15 '17 at 16:59
  • 1. Not necessary, it is important that I can create an e-mail with user given data (senders, content, etc.) and read mails based on their `ID`. We developed this now using `Microsoft.Interop`. To prevent rewrite all the code we strongly want to keep using the `Microsoft.Interop` libary. 2. The client application is a `TCP` server. In `JS` we create a websocket to the client (TCP-server) application, and send the data (like sender and content). So at the end it is the client application which creates the e-mail (using `Microsoft.Interop`).We only can't run this client application multiple times – S.Pols Jan 15 '17 at 17:09
  • In such a case you can basically drop the part of your question where you discuss JS server - it only confuses the reader. So you have some service that needs to send emails with `Microsoft.Interop`. Minor digression - have you read https://support.microsoft.com/en-us/kb/257757? And you have some issue with multiple users. What is that issue and how exactly it is related to `This is impossible, because there can only be 1 instance of the application listening to port 4001`. Usually services can perfectly handle multiple clients on the same port(that is what they have to do), so... – Eugene Podskal Jan 15 '17 at 17:38
  • Also, recommended reading - http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist – Eugene Podskal Jan 15 '17 at 17:40
  • Yes i saw it, but as far I can see it's the alternative for `Microsoft.Interop`. The problem is that the client application (TCP-server) needs to run on user-level. If the client applicaton is not running user-level it's not possible to use `Microsoft.Interop`. It is impossible to run the application on user-level cause the client application is a TCP-server and ofcourse you can't have 2 instances of TCP-servers listening to the same port. – S.Pols Jan 15 '17 at 17:47
  • `needs to run on user-level` - do you mean that application needs to [impersonate](http://stackoverflow.com/questions/125341/how-do-you-do-impersonation-in-net) user or that outlook interop requires [interactive user session(with desktop)](http://stackoverflow.com/questions/3128017/launching-a-process-in-user-s-session-from-a-service). And what that TCP server is? Is it WCF, or ASP.NET? – Eugene Podskal Jan 15 '17 at 20:53
  • And theoretically you can [listen to the same port from multiple applications](http://stackoverflow.com/questions/17212789/multiple-processes-listening-on-the-same-port), though it is not that simple and is probably inapplicable to your system. – Eugene Podskal Jan 15 '17 at 20:56

0 Answers0