c# - NuGet 更新后的 FileLoadException

标签 c# .net nuget unity-container

在更新所有 NuGet 包后,我的一个应用程序在启动时开始崩溃并出现 FileLoadException:

Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

这是在将 ServiceLocation 升级到版本 1.3.0.0 之后,我仔细检查了所有程序集以确保它们使用的是该版本。然后我运行 Fuslogvw 来诊断仍然引用旧版本的程序集:

LOG: DisplayName = Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/Charlie/AppData/Local/Programs/MyClient/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyClient.exe
Calling assembly : Microsoft.Practices.Prism.UnityExtensions, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===

因此,UnityExtensions(另一个 NuGet 包)仍然引用旧版本。但这应该没问题,因为我已经将 bindingRedirect 添加到我的 app.config 文件中:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.3.0.0" />
  </dependentAssembly>
</assemblyBinding>

但这似乎没有什么区别。我的应用程序以 .NET Framework 4.5.1 为目标,我已经尝试打开和关闭 AutoGenerateBindingRedirects。换句话说,我几乎什么都试过了。这是怎么回事?

最佳答案

解决此问题所需要做的就是更新所有项目中的所有 PRISM 和 Unity 相关包。不需要编辑绑定(bind)重定向。

查看详情 codeplex

关于c# - NuGet 更新后的 FileLoadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26475938/

相关文章:

.net - Nuget 包更新问题

c# - 在 Azure AD b2c 中创建新用户错误 : Another object with the same value for property proxyAddresses already exists

c# - 为什么 BufferedGraphics 绘制速度慢?

在VS2015中安装NuGet包时出现TFS204018错误

c# - 如何通过 NuGet 包共享源代码以用于 .NET Core 项目

c# - 几乎相同方法中的不同行为异步/等待

c# - 动态添加 DataGrid 日期时间列

c# - 字符串参数的 ArgumentException 或 ArgumentNullException?

c# - 将基本类型(日期、数字)转换为字符串并返回以保存到 C# 中的数据库

.net - 控制迭代循环内的递归