title: Could not load file or Assembly `System.Windows.Forms , Version=4.0.0.0` cannot find the file
body: <p>I am using reflection to search through assemblies that contain a certain interface, the one i am trying to find is a windows form that implements that interface, however the error i am getting claiming it cannot load the file, could it be down to not using reflection correctly or loading in the file properly.</p>
  <pre><code>string[] files = Directory.GetFiles(Environment.CurrentDirectory, &quot;*.dll&quot;);
  
              foreach (string file in files)
              {
                  try
                  {
                      Assembly da = Assembly.LoadFrom(file);
  
                      foreach (Type type in da.GetTypes())
                      {
                          debugger = (IDebugger)Activator.CreateInstance(type.GetInterfaces().First(i =&gt; i.IsGenericType &amp;&amp; i.GetGenericTypeDefinition() == typeof(IDebugger)));
                          break;
                      }
                      break;
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine(&quot;{0}: {1}&quot;, file, e.ToString());
                      continue;
                  }
              }
  
              if (!(debugger == null))
                  debugger.VirtualMachine = this;
  </code></pre>
  <p>Error</p>
  <pre><code>System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
  Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
     at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
     at System.Reflection.RuntimeModule.GetTypes()
     at System.Reflection.Assembly.GetTypes()
     at SVM.SvmVirtualMachine..ctor() in C:\Users\Ollie\Desktop\Work\SimpleVM\SVM\VirtualMachine\VirtualMachine\SvmVirtualMachine.cs:line 49
  System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
  File name: 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  </code></pre>
  <p>Value of the File</p>
  <pre><code>C:\Users\Ollie\Desktop\Work\SimpleVM\SVM\bin\Debug\Debugger.dll: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
  </code></pre>
  <p>Help from Lecturer - Fix (Only Fix available atm i believe)</p>
  <pre><code>- In the .csproj file 
  - Change &lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt; change this to &lt;Project Sdk=&quot;Microsoft.NET.Sdk.WindowsDesktop&quot;&gt; 
  - the &lt;PropertyGroup&gt; element with OutputType and TargetFramework nested inside it. Add a nested child before the &lt;/PropertyGroup&gt; tag: &lt;UseWindowsForms&gt;true&lt;/UseWindowsForms&gt;
  - Save and Rebuild
  </code></pre>