title: LoadFromContext Occurred
body: <p>I have a very simple C# problem that loads a Windows WPF window from a library. Here's the code:</p>
  
  <pre><code>public partial class App : Application
  {
      public App()
      {
          MainWindow mainWindow = new MainWindow();
          mainWindow.Show();
      }
  }
  </code></pre>
  
  <p>But when I run it breaks on the <code>mainWindow.Show();</code> line with the following error:</p>
  
  <blockquote>
    <p>Managed Debugging Assistant 'LoadFromContext' has detected a problem in 'C:\Users.....\bin\Debug\Test.vshost.exe'.</p>
    
    <p>Additional information: The assembly named 'WpfXamlDiagnosticsTap' was loaded from 
    'file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CLIENTDIAGNOSTICS/XAMLDIAGNOSTICS/x64/WpfXamlDiagnosticsTap.dll'
    using the LoadFrom context. </p>
    
    <p>The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies.</p>
  </blockquote>
  
  <p>The <code>MainWindow</code> class just extends from <code>System.Windows.Window;</code>
  I'm not exactly sure what this means and how to solve. Just upgraded to Visual Studio 2015.</p>
  
  <p><img src="https://i.stack.imgur.com/MsdsK.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/6vDM0.png" alt="enter image description here"></p>
  
  <p>If I ignore the exception and continue I get this when I close the last window:</p>
  
  <p><img src="https://i.stack.imgur.com/tiOKS.png" alt="enter image description here"></p>