views:

40

answers:

1

I need my application (Master) to run another application (Worker) on a particular event.

If I distribute my Worker application as a standard executable, then all is well, and I can use Process.Start with no problems and happily pass in arguments and call WaitForExit.

If I distribute my Worker application as a ClickOnce Application, it creates an Application Reference, which I can start with Process.Start (once I put a copy of it in the same directory as my Master.exe), but I cannot pass it arguments or use WaitForExit.

I want to be able to do both. I suspect the call to the reference starts another process which the Worker executable actually runs in.

My code:

// This works as I expect, and returns a valid Process.
Process p0 = Process.Start("Worker.exe", "DoSomeMagic");
// This seems to work, but returns null.
Process p1 = Process.Start("Worker.appref-ms");
// This also returns null, but does not pass the argument to Worker.
Process p2 = Process.Start("Worker.appref-ms", "DoSomeMagic"); 

My question:

How do I do this "properly"?

A: 

ClickOnce applications do not allow the passing of command-line arguments (or, in their case, arguments by query string) by default. You need to configure the appropriate option in the manifest file in order to allow them, but even then there are several caveats to consider. The whole ClickOnce platform imposes some very nasty limitations on how your applications can execute, as well as how they can be started. Of course, this is all under the guise of security, but personally I think it's short-sightedness.

More info here on how to pass arguments to ClickOnce apps: http://msdn.microsoft.com/en-us/library/ms172242.aspx

Bradley Smith