首页 > 解决方案 > 测试错误:无法加载文件或程序集'Castle.Core,版本 = 4.0.0.0,文化 = 中性

问题描述

我用架构 Asp.Net Mvc5.x 和 Single Page Web Application Angular JS 安装了 ASP.NET Boilerplate 的免费启动模板

并且当我将已添加的测试作为示例运行到模板时,该示例称为 Should_Get_Current_User_And_Tenant_When_Logged_In_As_Tenant() 可以在项目 SpecificDownloadedProjectName.Tests 中找到

我得到错误

Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我当前的 castle.core 版本是 v4.3.1

和 Abp 3.8.3

这些版本是 NuGet 包中最新的可用版本

我尝试通过 NuGet 包管理器将 Castle.core 更新为 4.0.0,正如异常消息中提到的那样,但我无法出现以下错误

Severity    Code    Description Project File    Line    Suppression State
Error       Unable to resolve dependencies. 'Castle.Core 4.0.0' is not compatible with 'Abp 3.8.3 constraint: Castle.Core (>= 4.3.1)', 'Castle.Core-log4net 4.3.1 constraint: Castle.Core (= 4.3.1)', 'Castle.DynamicProxy 2.2.0 constraint: Castle.Core (= 1.2.0)'.            0   

我应该怎么做才能解决这个异常

标签: aspnetboilerplate

解决方案


这是 Nuget 的问题,有时无法解决,因此您必须在 web.config 或 app.config 中手动添加以下行。您还必须确保行的顺序。

<dependentAssembly>
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.0.0.0" />
</dependentAssembly>

注意:您可以根据需要设置 oldVersion 和 newVersion 值。


推荐阅读