Getting Error.. Could Not Load File or Assembly 'System.Drawing,Version 4.0.0.0, Culture=natural...' error while converting from .net 4.0 to .net 3.5

24,448

Solution 1

It is a ratty problem with resources, as you can tell from the exception message, they also take a dependency on the framework version. Which is not changed by just changing the target version of your project.

Open the Resources.resx file in a text editor, Notepad will do. Search for "4.0.0.0" and change that to "2.0.0.0". That might not fix the problem, some resources are binary serialized and embedded as a base64 encoded string in the .resx file. You'll easily recognize them as a long string. You'll need to fix those with the Visual Studio resource editor, remove them and add them back.

Solution 2

You are referencing the System.Drawing assembly for the framework 4.0 (as you can read from the error) and not for the 3.5

You have to locate your System.Drawing reference and change it to 3.5.

The easiest way is to:

  1. Open you Project
  2. Go to Solution Explorer
  3. Expand the Reference group
  4. Delete the System.Drawing reference
  5. Right click on the Reference group
  6. Add Reference
  7. On the ".NET" tab, search for System.Drawing to add the right reference
Share:
24,448
Mohemmad K
Author by

Mohemmad K

Working as a trainee for ASP.Net with C#. I am a student of M.C.A.

Updated on March 04, 2020

Comments

  • Mohemmad K
    Mohemmad K over 4 years

    I am new to windows desktop application development.

    I have created an application using visual - studio 2010 in which I have used one form for data entry. One form with report viewer control and a report(.rdlc) file which report is drawn.

    My problem is that I want to make my application compatible for dot net framework 3.5. To do that, I have changed the target framework to 3.5 from the 'Advanced Compile Options...' from the project properties. But I am getting the error when I run the application after changing the target framework to 3.5 is :

    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. Line 123, position 5. C:\Users\Amir\Desktop\Bill_System\Bill_System\Bill_System\My Project\Resources.resx Billing_System

    How to tackle this error?

    Please help. Thanks in advance.