System wide bindingRedirect for F# 4.0.0.0 to 4.3.0.0

馋奶兔 提交于 2019-12-04 03:28:13

问题


I have some xUnit tests which are failing with the common

Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 
The system cannot find the file specified.

To perform a machine-wide redirect, I added to the file

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config 

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
                        culture="neutral"/>
      <bindingRedirect oldVersion="4.0.0.0" newVersion="4.3.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

Do you have a better way to deal with the 4.0 / 4.3 issue definitely ?


回答1:


I don't know xUnit, but if your unit test runner supports app.config files, you can just attach the config to the unit test assemblies (e.g. an app.config along the lines of what you get with a default F# console application template). If the test runner does not honor app.config, then I think the machine.config strategy is a decent one.




回答2:


By using NuGet, I added FSharp.Core.3 and it fixed my issue.



来源:https://stackoverflow.com/questions/11718385/system-wide-bindingredirect-for-f-4-0-0-0-to-4-3-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!