Reputation: 29
I have a C# solution with multiple WinFrom projects, and in this solution, I have a WPF project also. When I start a WinForm project as a process inside MainProject, it runs perfect and I can debug it without any problem. But when I want to start WPF project as a separate process inside MainProject, I can't debug it. I use Child Process Debugging Extension for debug child processes. My code for start child process :
Process.Start(new ProcessStartInfo()
{
FileName = System.Reflection.Assembly.GetAssembly(typeof(UI.Export.DTO.Launcher)).Location,
WorkingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(UI.Export.DTO.Launcher)).Location),
Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(launcher))),
});
I also add both WinForm and WPF projects to Child Process Debugging Settings!
Thanks in advance :)
Upvotes: 2
Views: 91
Reputation: 7325
I would
Application.Startup
Application.Startup
public partial class YourWpfApp : Application
{
public YourWpfApp()
{
Startup += YourWpfApp_Startup;
}
private void YourWpfApp_Startup(object sender, StartupEventArgs e)
{
System.Threading.Thread.Sleep(50000);//Attach to the process, while waiting here.
Startup -= YourWpfApp_Startup;
}
}
Upvotes: 1