I'm using MessageBox from Extended WPF Toolkit in WPF component, which hosted in Windows Forms application via ElementHost. To share some resources, I'm using this approach:
if (Application.Current != null)
{
Logger.Debug(Resources.ComponentBootstrapper_SkippingSharedResources);
return;
}
Logger.Debug(Resources.ComponentBootstrapper_CreatingApplication);
new Application();
foreach (var uri in SharedResourceDictionaries)
{
AddSharedResourceDictionary(uri);
}
This code works fine until somewhere in the WPF component's code MessageBox will be shown. Then, Application.Current in the code above returns null, but new Application() raises an exception, which tells, that I can't create more that one instances of Application per domain.
If calls to MessageBox being replaced by calls to System.Windows.MessageBox, everything works fine.
Comments: by design
if (Application.Current != null)
{
Logger.Debug(Resources.ComponentBootstrapper_SkippingSharedResources);
return;
}
Logger.Debug(Resources.ComponentBootstrapper_CreatingApplication);
new Application();
foreach (var uri in SharedResourceDictionaries)
{
AddSharedResourceDictionary(uri);
}
This code works fine until somewhere in the WPF component's code MessageBox will be shown. Then, Application.Current in the code above returns null, but new Application() raises an exception, which tells, that I can't create more that one instances of Application per domain.
If calls to MessageBox being replaced by calls to System.Windows.MessageBox, everything works fine.
Comments: by design