文件(或组件)可以在不改变项目的.NET目标框架,从4.0到3.5后发现不改变、组件、框架、目标

2023-09-03 01:45:02 作者:狗屎味的小仙女

我想改变我的C#项目,该项目是基于.NET 4.0至3.5。 所以我改变了项目的目标框架3.5。

在重新开放,并试图编译该项目出现错误:

  

文件或程序集System.Drawing中,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a或它的一个依赖找不到。系统无法找到该文件。   奥德EINEAbhängigkeitdavon wurde nicht gefunden。 DAS系统卡恩死angegebene Datei nicht芬登。

这发生在文件Resource.resx中,它看起来像:

 <装配别名为System.Windows.Forms的NAME =System.Windows.Forms的,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089/>
    <数据NAME =traktor_connectedTYPE =System.Resources.ResXFileRef,System.Windows.Forms的>
        <价值> .. \资源\ traktor_connected.png; System.Drawing.Bitmap,System.Drawing中,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a< /值GT;
    < /数据>
    <数据NAME =traktor_not_connectedTYPE =System.Resources.ResXFileRef,System.Windows.Forms的>
        <价值> .. \资源\ TRAKTOR  - 不connected.png; System.Drawing.Bitmap,System.Drawing中,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a< /值GT;
    < /数据>
 
wpf在vs2015目标框架.net4.0下不能生成style

解决方案

该引用指向.NET 4 - 你需要删除所有的.NET 4的参考,然后使用.NET 3.5版的assemly的重新进行添加,然后它的工作

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>

解决方案

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