我将Visual Studio从VS2017升级到了VS2019。我打开了一个包含C#和F#的解决方案。一个C#单元测试项目引用了一个F# .dll项目。
这个解决方案编译没有问题,但在运行时,我得到了以下消息:
System.IO.FileLoadException: '无法加载文件或程序集“FSharp.Core,Version=4.6.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其某个依赖项。所定位的程序集清单定义与程序集引用不匹配。(HRESULT 的异常:0x80131040)'
内部异常是:
Could not load file or assembly 'FSharp.Core, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我在单元测试的app.config中有以下内容:
这个解决方案编译没有问题,但在运行时,我得到了以下消息:
System.IO.FileLoadException: '无法加载文件或程序集“FSharp.Core,Version=4.6.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其某个依赖项。所定位的程序集清单定义与程序集引用不匹配。(HRESULT 的异常:0x80131040)'
内部异常是:
Could not load file or assembly 'FSharp.Core, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我在单元测试的app.config中有以下内容:
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.6.2.0" newVersion="4.6.2.0" />
</dependentAssembly>
单元测试项目在packages.config文件中有此内容
<package id="FSharp.Core" version="4.6.2" targetFramework="net461" />
我是否没有看到一个缺失的引用?
谢谢。
bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.6.0.0"
。我正在使用 NUnit。你能否尝试将重定向改为4.6.0.0,看看是否有所帮助?我怀疑我遇到了同样的内部异常,并最终找到这个奇怪的解决方案。 - Bent Tranberg