views:

53

answers:

2

I want to change my C# project, which is based on the .NET 4.0 to 3.5. So I changed the project's target-framework to 3.5.

After re-opening and trying to compile the project I get the error:

The file or assembly "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or one of its dependencies couldn't be found. The system can't find the file. oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

This happens in the file Resource.resx, which looks like that:

<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <data name="traktor_connected" type="System.Resources.ResXFileRef, System.Windows.Forms">
        <value>..\Resources\traktor_connected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
    </data>
    <data name="traktor_not_connected" type="System.Resources.ResXFileRef, System.Windows.Forms">
        <value>..\Resources\traktor-not-connected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
    </data>
+3  A: 

That reference is pointing to .Net 4 - you need to remove all .net 4 references and then readd them using the .net 3.5 version of the assemly and then it will work

paul

PaulStack
Just changing them to Version 3.5.0.0 doesn't seem to be enough.Do you mean re-adding the references in the project-explorer too?
Hedge
yeah you need to remove the references and then readd them - as the hardcoded 4.0.0.0 that you changed do not represent the actual versions of the .dll now
PaulStack
+1  A: 

Changing the Target framework setting is not exactly perfect. In a C# project for example you have to remove the reference to Microsoft.CSharp by hand. And yes, it doesn't automatically update the System.Drawing assembly references in the .resx files. This is probably on the to-do list for VS2010, hopefully covered by SP1.

For now, you'll have to remove the resources and add them back after changing the target framework. Editing the .resx file by hand is possible too. You only have to change the Version to 2.0.0.0, the PublicKeyToken value is the same.

Hans Passant