Here is some information from Microsoft on how to support UI in the seamless debugger. I hope this is helpful.
It is actually possible for add-in to use WinForm or WPF. For WinForm, you cannot just call form1.Show(), you need to call either ShowDialog or Application.Run to set up the message pump. For WPF, you have to spawn a STA thread to do it.
For example:
public void MacroWinForm()
{
bool useNewThread = false;
if (useNewThread)
{
Thread t = new Thread(() =>
{
Form1 myWinForm = new Form1();
System.Windows.Forms.Application.Run(myWinForm);
});
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
MessageBox.Show("Winform new thread");
}
else // works if using ShowDialog, will block if using Show and without using System.Windows.Forms.Application.Run.
{
Form1 myWinForm = new Form1();
myWinForm.ShowDialog(); // Modal
//System.Windows.Forms.Application.Run(myWinForm); // Modeless
MessageBox.Show("Winform same thread");
}
}
public void MacroWPF()
{
bool useNewThread = true;
if (useNewThread)
{
Thread t = new Thread(() =>
{
System.Windows.Window w = new System.Windows.Window();
System.Windows.Application app = new System.Windows.Application();
app.Run(w);
});
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
MessageBox.Show("Winform new thread");
}
else // Won't work without creating a new thread
{
System.Windows.Window w = new System.Windows.Window();
System.Windows.Application app = new System.Windows.Application();
app.Run(w);
MessageBox.Show("Winform same thread");
}
}