Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Could not load file or assembly System.Drawing or one of its dependencies" error on .Net 2.0, VS2010 and Windows 8
    text
    copied!<p>I am getting a FileNotFoundException on a Windows Forms Application project, with the following message: </p> <blockquote> <pre><code>Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. </code></pre> </blockquote> <p>To replicate the problem: </p> <ul> <li>Select New, Project, choose .Net Framework 2.0 as the target and pick Windows Forms Application as the project type.</li> <li>On the properties of the form created by default, select a value for the Icon property. Any .ico file will do. This will embed the file on the resx file.</li> <li>Compile and run the application.</li> </ul> <p>When I do this, the program stops on the line <code>this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));</code> with the following exception:</p> <pre><code>System.IO.FileNotFoundException was unhandled Message=Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Source=mscorlib FileName=System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a </code></pre> <p>I’m getting this on Visual Studio 2010 SP1, recently installed on Windows 8 Developer Preview. If I change the project properties to target .Net Framework 4, the error goes away.</p> <p>On the Form1.resx file, I can see that the version of the System.Drawing assembly is explicitly stated as 2.0:</p> <pre><code>&lt;assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt; </code></pre> <p>Any ideas?</p>
 

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