我有一个针对 F# runtime 4.4.1 的单元测试项目。它有一个带有 bindingRedirect 部分的 app.config:
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.1.0" />
</dependentAssembly>
但是,当我运行测试时出现运行时错误:
Could not load file or assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
我想知道为什么会尝试加载 FSharp.Core 4.3.0.0,因为 bindingRedirect 指定了不同的版本。
最佳答案
显然这是 XUnit 配置的问题。 app.config 中的以下部分更改了 AppDomain 配置:
<appSettings>
<add key="xunit.appDomain" value="required" />
</appSettings>
然后测试运行器提示缺少 xunit.execution.desktop.dll。一旦文件被放置在执行目录中,XUnit 运行器就会使用 bindingRedirect 设置来验证 app.config。
关于f# - 为什么 bindingRedirect 不影响 FSharp.Core 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46172340/