当我没有app.config文件时编译器告诉我“考虑app.config重映射”时应该更改什么?

时间:2013-10-03 16:21:17

标签: visual-studio-2008 assemblies app-config versioning resx

在编译从VS2003中的.NET 1.1移植到VS2008中的.NET 3.5的解决方案时,我得到了一些建议,其中一个是代表性的:

考虑app.config重新映射程序集“System.Windows.Forms,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes”从版本“1.0.5000.0”[]到版本“2.0.0.0”[C :\ Program Files(x86)\ Microsoft.NET \ SDK \ CompactFramework \ v2.0 \ WindowsCE \ System.Windows.Forms.dll]解决冲突并摆脱警告。

解决方案中的任何项目都没有app.config文件。但是,有很多* .resx文件包含“Version = 1.0.5000.0”

我应该进行全局搜索并替换那些“Version = 2.0.0.0”或者我应该如何纠正这个问题?

更新

我选择了“项目>升级项目”,重建,现在消息包括:

C:\ Windows \ Microsoft.NET \ Framework \ v3.5 \ Microsoft.Common.targets:警告MSB3245:无法解析此引用。找不到程序集“System.Windows.Forms.DataGrid”。检查以确保磁盘上存在程序集。如果您的代码需要此引用,则可能会出现编译错误。

无法解决“System.Xml,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes”和“System.Xml,Version = 2.0.0.0,Culture = neutral”之间的冲突,PublicKeyToken = b77a5c561934e089“。 选择“System.Xml,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes”任意。

无法解决“System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes”和“System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089”之间的冲突”。选择“System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes”任意。

考虑app.config重新映射程序集“System.Windows.Forms,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes”从版本“1.0.5000.0”[]到版本“3.5.0.0”[C :\ Program Files(x86)\ Microsoft.NET \ SDK \ CompactFramework \ v3.5 \ WindowsCE \ System.Windows.Forms.dll]解决冲突并摆脱警告。

更新2

我的代码中有这一行:

this.dtGridUPC = new System.Windows.Forms.DataGrid(); 

尽管编译器警告我:“找不到程序集”System.Windows.Forms.DataGrid“。检查以确保程序集存在于磁盘上。如果代码需要此引用,您可能会收到编译错误。

...我没有编译错误。

Curiouser和curiouser。

5 个答案:

答案 0 :(得分:7)

您可以添加app.config文件,然后映射这样的库:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="dotless.ClientOnly" publicKeyToken="96b446c9e63eae34" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0" />
      </dependentAssembly>

答案 1 :(得分:2)

在我的情况下在输出窗口中显示的以下警告:

11>  Consider app.config remapping of assembly "log4net, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" from Version "1.2.15.0" [] to Version "2.0.12.0" [C:\s\[SolutionName]\log4net.dll] to solve conflict and get rid of warning.
11>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="log4net" culture="neutral" publicKeyToken="669e0ddf0bb1aa2a" /><bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0" /></dependentAssembly></assemblyBinding>

当我在“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets”文件打开的输出窗口中单击此警告时。我很惊讶我应该更改解决方案文件夹之外的内容。另一个惊喜是即使我使用 web.config 配置文件处理 Web 服务,我也应该更改 app.config。程序员可能没有意识到,这个警告也显示了对服务...

无论如何,请在“错误列表”窗口而不是“输出”窗口中双击此警告。确保按下“错误列表”窗口顶部的“警告”按钮,以便您可以在“错误列表”窗口中看到此警告。这样你就应该以适当的方式解决这个警告。

答案 2 :(得分:1)

我添加了一个带有此代码的app.config文件,我的编译时间现在是它的1/3。这是针对System.Data

function layoutNEW(divName){
var hiddenVal = document.getElementById("tempDivName");
if(hiddenVal.Value != undefined){
    var oldDiv = document.getElementById(hiddenVal.Value); 
    oldDiv.style.display = 'none'; 
}
var tempDiv = document.getElementsByClassName(divName);
for ( var i=0, len=tempDiv.length; i<len; ++i ){
    tempDiv[i].style.display = 'block';  
}
hiddenVal.Value = document.getElementById(divName).getAttribute("id");}

我在这里找到了这段代码:http://grenangen.se/node/25#comment-1003

答案 3 :(得分:1)

我刚刚修复此错误非常简单。关闭你的项目。再次打开。转到NuGet包获取解决方案。你将有一个部分巩固。就在搜索工具附近。 去那里,选择你想要使用的版本。还要确保所有项目都具有相同的版本。 然后在所有解决方案中添加缺少的库,直到您的命现在编译你的项目,我希望它能再次开始工作。

答案 4 :(得分:1)

请在Visual Studio的项目属性窗口中使用Auto-generate binding redirects

enter image description here

相关问题