Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF - C#: This element is not currently associated with any context
    primarykey
    data
    text
    <p>I have a WPF UserControl, which I use in a WinForms Control within an ElementHostControl. Then I start a WPF Window, while the Windows Form is still open. If I then close the WPF Window, and try to add a Child Element to my WPF UserControl, it crashes at "InitializeComponent()" (of the Child Element) with the exception:</p> <blockquote> <p>"A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll. Additional information: This element is not currently associated with any context"</p> </blockquote> <p>I found out why it happens, but I don't know how to solve the problem. If I leave out this code:</p> <pre><code>public static void EnsureApplicationResources() { if (Application.Current == null) { // create the Application object new Application(); string assemblyName = System.IO.Path.GetFileNameWithoutExtension( Assembly.GetExecutingAssembly().ManifestModule.Name); // merge in your application resources Application.Current.Resources.MergedDictionaries.Add( Application.LoadComponent(new Uri("/KolonistenClient;component/KolonistenResourceDictionary.xaml", UriKind.RelativeOrAbsolute)) as ResourceDictionary); } } </code></pre> <p>then everything is fine. I need that though, because of the fact that my ResourceDictionary (and thus also my defined styles and templates) is otherwise not available throughout the WPF Window and Controls. <a href="http://drwpf.com/blog/2007/10/05/managing-application-resources-when-wpf-is-hosted/" rel="nofollow noreferrer">This I found out about here</a></p> <p>Is there any way to combine the best of both worlds? Keeping my ResourceDictionary, while preventing the application from crashing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload