I have a WinForms application that accepts a command line argument by calling Environment.GetCommandLineArgs()
and does something with it.
It works fine in Debug mode - I enter the argument in the Debug tab of Project Properties, then run it (F5) and the application gets the argument correctly.
But after I publish the application and try to call it from another Winform application with this code line:
Process.Start("\\path\to\myApp\MyApp.application", "4")
it doesn't work. Apparently the argument is not passed to the application for some reason, and I don't know why. I also tried to create a new process and set its ProcessStartInfo.Arguments
before starting it, but it still doesn't work.
Can anyone help me?
UPDATE
It seems to me that when Process.Start("\\path\to\etc", "4")
is called, what is actually run is the local copy of the program on my machine, located at C:\users\myUserName\AppData\Local\App\2.0\long-string-of-digits-and-letters\MyApp.exe
. If I run Process.Start("C:\users\etc", "4")
instead - it works.
Now my question is - why wasn't the argument passed to the local copy of the program when running Process.Start("\\path\to\etc", "4")
? What should I do so that the argument is passed to the local copy?