【问题标题】:What should I change when the compiler tells me to "Consider app.config remapping" when I have no app.config file?当我没有 app.config 文件时,当编译器告诉我“考虑 app.config 重新映射”时,我应该改变什么?
【发布时间】:2013-10-10 10:47:07
【问题描述】:

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

考虑将程序集“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”。

考虑将程序集“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”。检查以确保程序集存在于磁盘上。如果您的代码需要此引用,您可能会遇到编译错误。"

...我没有收到任何编译错误。

好奇者和好奇者。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 至少也升级到 4.7.2。很多问题都消失了。
    • 这只是我两天构建地狱的解决方案。谢谢!
    【解决方案2】:

    您可以添加一个 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>
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

        我用这段代码添加了一个 app.config 文件,我的编译时间现在是原来的 1/3。这是用于 System.Data

        <configuration>
            <runtime>
                <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
                    <!-- 2.0 to 3.5 -->
                    <dependentassembly>
                        <assemblyidentity culture="neutral" publickeytoken="969db8053d3322ac" name="System.Data" />
                        <bindingredirect newVersion="3.5.0.0" oldVersion="2.0.0.0" />
                    </dependentassembly>
        
                    <!-- 1.0 to 3.5 -->
                    <dependentassembly>
                        <assemblyidentity culture="neutral" publickeytoken="969db8053d3322ac" name="System.Data" />
                        <bindingredirect newVersion="3.5.0.0" oldVersion="1.0.5000.0" />
                    </dependentassembly>
                </assemblybinding>
            </runtime>
        </configuration>
        

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

        【讨论】:

          【解决方案5】:

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

          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。程序员可能没有意识到这个警告也适用于服务......

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

          【讨论】:

            猜你喜欢
            • 2016-07-21
            • 2018-01-08
            • 2011-12-18
            • 1970-01-01
            • 2012-07-13
            • 1970-01-01
            • 1970-01-01
            • 2015-04-12
            • 2012-05-26
            相关资源
            最近更新 更多