What is the best practice for a (.Net 2.0) application that is limited
to a single instance and has file associations?

There appear to be two methods for communicating verbs between Explorer
and an application: command line and DDE.

Going w/ the command line route, if there is already an instance of my
application running, I need to detect that, and then communicate the
command line to the 'main' instance using ? Remoting, I guess?

Using the DDE route: this seems like the more standard route, however
I'm not seeing anything that immediately supports this in the .Net
Framework. ? There has to be something, as this is Windows standard
behavior since when...

Anyone have any thoughts/comments/pointers/suggestions on what is
best/standard practice for handling file association verb requests in .Net?

Thanks!

RE: Best practice for single instance and file associations? by jetan

jetan
Mon Nov 26 18:41:11 PST 2007

Hi Julie,

Normally, the easiest way of implementing single instance application is
using global named mutex. The principle of this approach leverages the fact
that mutex kernel object can have a global name associated with it.
Multiple processes can see the same registered name. So if the first
process has created the name, the second instance(process)'s creation will
fail.


Re: Best practice for single instance and file associations? by Julie

Julie
Wed Nov 28 16:27:35 PST 2007

Jeffrey Tan[MSFT] wrote:
> Hi Julie,
>
> The remind requirement is passing the command line argument of the second
> instance to the first running instance. You can leverage any type of
> inter-process communication technologies to get this done, such as named
> pipe, socket, Remoting etc.. Sure, since .Net only has native support for
> Net Remoting, it is recommended to use it. The article below demonstrated
> this:
> "Single Instance Application, Passing Command Line Arguments"
> http://www.codeproject.com/cs/threads/SingletonApp.asp

Perfect -- thanks.