I am getting a FileNotFoundException on a Windows Forms Application project, with the following 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.
To replicate the problem:
When I do this, the program stops on the line this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
with the following exception:
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
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.
On the Form1.resx file, I can see that the version of the System.Drawing assembly is explicitly stated as 2.0:
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Any ideas?
I've found a possible solution, please try this:
Open the resx File in the Designer and set the accessmodifier from public to no code generation.
Edit: there's a workaround, but very annoying though.
**NOTE: the only difference are the characters at end "j00LjAuMC4w' to "j0yLjAuMC4w" This needs to be done EVERY TIME you open the form in Designer mode.
Microsoft says they are going to fix it in the next VS version...