I got following setup:
WPF_Application.exe
and
a DLL that contains a WinForms Window and an WPF Window.
The 'WPF_Application.exe' calls the WinForms window from the DLL and the WinForms Window creates an instance of the WPF window in the DLL.
That creates following exception:
Cannot create more than one System.Windows.Application instance in the same AppDomain.
Tried different things, but couldn't figure out how to fix it.
I fixed it by asigning the Application of the wpf window that is called to the Application.Current Window:
if (Application.Current == null)
{
MyApplication = new Application
{
ShutdownMode = ShutdownMode.OnExplicitShutdown
};
}
else
MyApplication = Application.Current;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With