tags:

views:

49

answers:

2

We are using this code to launch a Wpf form:

string fileName = @"C:\Test\bin\Debug\WpfTest.exe";
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(fileName);
            psi.Arguments = entryZfName;
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo = psi;
            p.Start();

The WpfTest is an appliation which contain a WPFForm1.xaml which gets launched. How to access the arguments in this form that were set to psi in the above code. Are they accessible in the constructor? Also how to debug this scenario, in other words since i am launching the wpftest.exe directly from the code i am not able to debug or access the code, is it possible to debug this. Let me know if you need more info

A: 

You can get your command line args from Environment.GetCommandLineArgs, or from the constructor as you have noted.

You can debug the process by opening up its solution in Visual Studio, going to the Debug menu, and choosing "Attach to Process". You can then attach to WpfTest.exe and debug it as if you had started it from Visual Studio.

dsolimano
A: 

you can use Environment.GetCommandLineArgs to get args. To Debug you can add Debug.Launch() in the wpf form or the place you want to start debugging if you have access to the code..

Deepak N
DeepakThere is no launch method for System.Diagnostics.Debug
np
I believe he was referring to System.Diagnostics.Debugger.Launch - http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.launch.aspx
dsolimano
Do you mean something like this:System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(fileName); psi.Arguments = entryZfName; System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo = psi; System.Diagnostics.Debugger.Launch(); p.Start();
np
No, you would have to do Debugger.Launch() in the WpfTest.exe process if you want a debugger prompt to pop up. It's probably easier to just attach a debugger, as in my answer.
dsolimano