0

I have a systemtray application (C#, Windows Forms). Next to this executable I will have another x amount of executables (written in C#) that must somehow send a message (preferably in string format) to the system tray application.

  • I do NOT want to install an entire Windows service for this.
  • It is NOT client-server. It all happens on the same PC. Using a listener combined with sockets would be to troublesome and it might even be blocked by it's own firewall I think.
  • I'm looking for something similar to a console application that can handle parameters on it's main function. Only this time for an already running Windows Form application.
  • Is it possible to somehow make a global function/procedure in the system tray application that can be called by other executables? Like "global void PerformAction(params here){..}"? This would seem to be the best solution but I'm not sure if .NET 4 supports this.

Example: executable X1.exe sends message "perform action [A] param [B]" to the system tray application and then terminates itself. The system tray application will then read that string and then knows that it needs to call function A with parameter "B".

But how do I send/receive the message?

Thank you.

2
  • 2
    What you are looking for is a wcf service over named pipe, hosted by the listening app (the tray app), i think Commented Sep 6, 2012 at 13:09
  • Or, in more specific contexts, you can use url moniker to register your own protocol handler. Commented Sep 6, 2012 at 13:11

5 Answers 5

1

Without resorting to WCF - you can use a simple wrapper over Named Pipes - like this one I posted as an answer to another question.

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

1

For local communication you could try anonymous pipes.

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

You can also check out the remote method invocation. Here is an example:

http://www.codeproject.com/Articles/14791/NET-Remoting-with-an-easy-example

1 Comment

You should avoid simply linking to a resource without summarizing it's contents here. When the link breaks your answer will no longer be relevant.
0

There is a very handy method available to native application, i.e. window messages. With some hack, you can also use it with your .net application.

I would suggest you to refer to

SendMessage and SendMessageA api functions. You might have to write some unsafe code though.

Comments

0

If you used self hosted Asp.Net Web API, then you could use simple http calls to that application to execute methods. This is nice because you can test it using fiddler or anything that can send an http request.

Here is a link for an example. http://www.asp.net/web-api/overview/hosting-aspnet-web-api/self-host-a-web-api

Comments

0

The easiest solution to me seemed to use a WCF service (inside the tray application) as Steve B mentioned. I used this tutorial: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication.

I haven't heard of piping before but I think that the above link uses a WCF Service with piping. It did solve my problem.

Thanks for the many solutions provided (and so fast).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.