How to run/invoke a WPF application (.exe) from a Windows Forms ? I know it can be done like shown below:
Process.Start(@"C:\ABC\WPF.exe");
But I want to send few parameters to the WPF Applications from the winform application. How to do it ?
Refer to complete code from here
You can pass arguments from your winform app like
Process.Start(new ProcessStartInfo(@"C:\repos\WpfApp.exe", "Args from WinForms"));
and receive in WPF app like
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (e.Args.Length > 0)
{
MessageBox.Show($"You have passed:{e.Args.Length} arguments," +
$" value are {string.Join( ",",e.Args)}");
}
}
}
"./WPFApp/Wpfapp.exe" will not work. If you include the wpf binaries in the winform project, this should work: AppDomain.CurrentDomain.BaseDirectory + @"WPFApp\WpfApp.exe";
Process.Start()has some overloads. One of them allows to supply the arguments.