开发者

Running an "Application Reference"

开发者 https://www.devze.com 2023-01-12 13:35 出处:网络
I need my application (Master) to run another application (Worker) on a particular event. If I dis开发者_运维知识库tribute my Worker application as a standard executable, then all is well, and I can

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

If I dis开发者_运维知识库tribute 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"?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消