gpt4 book ai didi

c# - Moq.CaSTLeProxyFactory' 无法加载文件或程序集 'CaSTLe.Core

转载 作者:行者123 更新时间:2023-11-30 22:59:06 32 4
gpt4 key购买 nike

当我尝试像这样设置最小起订量对象时:

mock.Setup(reader => reader.listOFs(1)).Returns(new List<IIAM_OF_Event>() { new IIAM_OF_Event() { ID = 11 } }.AsQueryable());

它抛出

System.TypeInitializationException:“Moq.ProxyFactory”的类型初始值设定项引发异常。 ---

System.TypeInitializationException: The type initializer for 'Moq.CastleProxyFactory' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Castle.Core, Version=4.1.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) ---> System.IO.FileLoadException: 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)

IIAM_OF_Event 是一个 Linq 表。

最佳答案

测试中集成的一个组件以某种方式要求版本 CaSTLe.Core 4.1.0.0,但构建中包含的版本是 4.0.0.0。

我在配置文件中添加了这个:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
...

关于c# - Moq.CaSTLeProxyFactory' 无法加载文件或程序集 'CaSTLe.Core,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52480119/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com