I am trying to invoke one wpf application from another wpf application. The invoking wpf application makes the call
ProcessStartInfo BOM = new ProcessStartInfo();
BOM.FileName = @"D:\WPFAPPLICATION.exe";
BOM.Arguments = temp;
Process.Start(BOM);
Now in the invoked application, I try to retrieve the argument passed using
string arguments =Process.GetCurrentProcess().StartInfo.Arguments;
However the arguments are not passed. why is this??
I also tried an alternative method where in:
public partial class App : Application
{
public static String[] mArgs;
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length > 0)
{
mArgs = e.Args;
}
}
}
}
However this did not work either!!! Please HELP!!
Well I finally found a solution to my question if anyones interested. While in the calling application I maintained the same code I previously used:
ProcessStartInfo BOM = new ProcessStartInfo();
BOM.FileName = @"D:\WPFAPPLICATION.exe";
BOM.Arguments = temp;
Process.Start(BOM);
In the called application in order to receive arguments successfully I simply had to :
System.Text.StringBuilder strbuilder= new System.Text.StringBuilder();
foreach (String arg in Environment.GetCommandLineArgs())
{
strbuilder.AppendLine(arg);
barcode = arg;
}
psnfo = strbuilder.ToString();
I was not handling the arguments passed to the process in the correct manner
so upon displaying psnfo
The code returns :
D:\WPFAPPLICATION.exe temp
Source : http://www.codeproject.com/Questions/386260/Using-process-start-in-a-wpf-application-to-invoke