c# - 更新后 System.Reflection 多个程序集错误

标签 c# .net reflection reference nuget

将我的解决方案引用的 .NET Framework NuGet 包更新为上一个预发布版本。我有一个构建错误:

Multiple assemblies with equivalent identity have been imported: 'C:\Projects\RP\packages\System.Reflection.4.1.0-beta-23516\lib\net46\System.Reflection.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6\Facades\System.Reflection.dll'. Remove one of the duplicate references.

我不知道如何解决这个问题。如果我使用 NuGet 删除 System.Reflection,它会抛出引用错误异常,它需要 System.Reflection v.4.1.0.0。

Could not load file or assembly 'System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

如何删除重复项?

最佳答案

通过更改 app.config 中的这一行解决了问题:

<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />

<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />

在 Visual Studio 项目中管理 .NET Framework 包很麻烦。 有关引用的信息存在于 .csproj/.vbprojapp.configpackages.config 中。

关于c# - 更新后 System.Reflection 多个程序集错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33895816/

相关文章:

c# - 返回 bool 值和字符串值的最佳做法是什么

c# - 在没有连接字符串的情况下处理项目

c# - 什么时候应该在 C# 中使用 as 关键字

reflection - 根据数据类信息自动创建 TableView 列

c# - 构建环境设置 - 使用 .net、java、hudson 和 ruby​​ - 真的可以使用批评

c# - 如何从 DbProviderFactories 中删除提供者?

c# - 在 C# 中将大十进制值舍入到小十进制值

c# - 如何检索 .NET 运行时生成的所有封闭泛型类型的列表?

c# - 如何使用反射调用 IDBSet<T>.FirstOrDefault(predicate)?

c# - 如何确定哪个属性是数据绑定(bind)的默认属性?