title: Porting Windows Forms to .Net Standard 2.0
body: <p>Apologies if this is a very naive question. I wrote a Windows Form application using .Net 4.5 sometime ago. Recently, I thought it would be a good idea to port it to a .Net Standard 2.0 application using VS Code.</p>
  <p>There were a couple of problems with missing libraries and classes (System.ServiceModel being the biggest gap), but I have got to the point of building the application successfully. However, when I come to run it, I see the following error:</p>
  <blockquote>
  <p>Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058) ---&gt; System.BadImageFormatException: Cannot load a reference assembly for execution.</p>
  </blockquote>
  <p>Here's the project file if it's useful:</p>
  <pre><code>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
  
  &lt;ItemGroup&gt;
  &lt;PackageReference Include=&quot;log4net&quot; Version=&quot;2.0.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.CSharp&quot; Version=&quot;4.4.0&quot; /&gt;
  &lt;PackageReference Include=&quot;Newtonsoft.Json&quot; Version=&quot;10.0.3&quot; /&gt;
  &lt;PackageReference Include=&quot;NUnit&quot; Version=&quot;3.8.1&quot; /&gt;
  &lt;PackageReference Include=&quot;System.CodeDom&quot; Version=&quot;4.4.0&quot; /&gt;
  &lt;PackageReference Include=&quot;System.Configuration&quot; Version=&quot;2.0.5&quot; /&gt;
  &lt;PackageReference Include=&quot;System.Configuration.ConfigurationManager&quot; Version=&quot;4.4.0&quot; /&gt;
  &lt;PackageReference Include=&quot;System.Net.Http&quot; Version=&quot;4.3.3&quot; /&gt;
  &lt;PackageReference Include=&quot;System.ServiceModel&quot; Version=&quot;1.0.0&quot; /&gt;
  &lt;PackageReference Include=&quot;System.ServiceModel.Security&quot; Version=&quot;4.4.0&quot; /&gt;
  &lt;PackageReference Include=&quot;System.Windows.Forms&quot; Version=&quot;4.0.0.0&quot; /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;PropertyGroup&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;TargetFramework&gt;netcoreapp2.0&lt;/TargetFramework&gt;
  &lt;/PropertyGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  <p>Is there some way to run the application using the System.Windows.Forms library, or should I replace it with a different library for .Net Standard 2.0?</p>