title: C# FileNotFoundException was unhandled by user code
body: <p>So, I have a C# application with a GUI that's been written in XAML. My application was running and displaying correctly a moment ago, however, after making some minor changes to one of the GUI elements in the XAML (literally just resizing and moving a button), I built my code again, but now when trying to run it, I get and error message that says:</p>
  
  <blockquote>
    <p>FileNotFoundException was unhandled by user code</p>
  </blockquote>
  
  <p>The error is highlighting the line:</p>
  
  <pre><code>WebKit.WebKitBrowser browser = new WebKit.Browser();
  </code></pre>
  
  <p>in my <code>MainWindow.xaml.cs</code> file (<code>MainWindow.xaml</code> being the GUI source file where I repositioned one of the GUI elements).</p>
  
  <p>I have come across this error before, and fixed it by going to Project --> Add Reference, and checking the tick box for 'WindowsFormsIntegration'... However, I have double checked this, and it is still selected.</p>
  
  <p>I have looked in my folder structure, and can see that the <code>WebKit.Interop.dll</code> file is present in both my Debug and Release folders...</p>
  
  <p>I have also tried undoing the changes I made to the GUI, rebuilding, and running the code again, but I get the same error.</p>
  
  <p>Anyone have any ideas why this is? Have I accidentally clicked/ pressed something I shouldn't have? How can I resolve this issue?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>When I click 'View Detail...' on the <code>FileNotFoundException was unhandled by user code</code> message that's displayed, the <code>System.IO.FileNotFoundException</code> says:</p>
  
  <blockquote>
    <p>{"Could not load file or assembly 'WebKit.Interop, Version=533.0.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be' or one of its dependencies. The system cannot find the file specified.":"WebKit.Interop, Version=533.0.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be"}</p>
  </blockquote>
  
  <p>The <code>InnerException</code> has value:</p>
  
  <blockquote>
    <p>null</p>
  </blockquote>
  
  <p>The <code>FileName</code> is:</p>
  
  <blockquote>
    <p>WebKit.Interop, Version=533.0.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be</p>
  </blockquote>
  
  <p>The <code>FusionLog</code> is:</p>
  
  <blockquote>
    <p>=== Pre-bind state information ===
    LOG: DisplayName = WebKit.Interop, Version=533.0.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be
     (Fully-specified)
    LOG: Appbase = file:///C:/.../bin/Debug/
    LOG: Initial PrivatePath = NULL</p>
    
    <h1>Calling assembly : WebKitBrowser, Version=0.5.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be.</h1>
    
    <p>LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:...\bin\Debug\WpfApplication1.vshost.exe.Config
    LOG: Using host configuration file: 
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: WebKit.Interop, Version=533.0.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be
    LOG: Attempting download of new URL file:///C:/.../bin/Debug/WebKit.Interop.DLL.
    LOG: Attempting download of new URL file:///C:/.../bin/Debug/WebKit.Interop/WebKit.Interop.DLL.
    LOG: Attempting download of new URL file:///C:/.../bin/Debug/WebKit.Interop.EXE.
    LOG: Attempting download of new URL file:///C:/.../bin/Debug/WebKit.Interop/WebKit.Interop.EXE.</p>
  </blockquote>
  
  <p>When I look in the folder location specified by the <code>FusionLog</code>, I can see the <code>WpfApplication1.vshost.exe</code> file it's looking for... (there are <code>WpfApplication1.vshost</code> Application Manifest, <code>WpfApplication1.vshost</code> Application, <code>WpfApplication1.vshost.exe</code> XML Configuration &amp; <code>WpfApplication1.vshost.exe.manifest</code> MANIFEST files all in that location... (and a few others: <code>.exe</code>, <code>.exe.manifest</code> <code>Source Browser Database</code>, etc)</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The code where this exception is occurring is just above the constructor for my <code>MainWindow.xaml.cs</code> class, i.e. where I am declaring the global variables for that class:</p>
  
  <pre><code>using Newtonsoft.Json.Linq;
  using System;
  using System.Collections.Generic;
  using System.Windows;
  using System.Windows.Controls;
  using System.Threading;
  using System.Threading.Tasks;
  using System.Diagnostics;
  using System.IO;
  using System.Text;
  using System.Xml;
  using System.Windows.Media;
  using System.Windows.Forms;
  using WebKit;
  using System.Collections;
  
  namespace Agent
  {
      public partial class MainWindow : Window
      {
          ...
          System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
          WebKit.WebKitBrowser browser = new WebKit.WebKitBrowser();
  
          ...
      }
  }
  </code></pre>
  
  <p>The exception is being thrown on the line:</p>
  
  <pre><code>WebKit.WebKitBrowser browser = new WebKit.WebKitBrowser();
  </code></pre>
  
  <p>and says that it </p>
  
  <blockquote>
    <p>Could not load the file or assembly WebKit.Interop, Version 533.0.0.0 ...</p>
  </blockquote>