FSharp.Core: Could not load file or assembly

送分小仙女□ 提交于 2019-12-31 03:33:07

问题


I have the following error when attempting to run a test:

{System.IO.FileLoadException: Could not load file or assembly 'FSharp.Core, Version=3.3.1.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) File name: 'FSharp.Core, Version=3.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Register.RegisterResponse.__DebugDisplay()

Tests.dll

FSharp.Core: 3.1.2.5

Target F# runtime: 4.3.1.0

Target Framework: 4.6

Output type: Class Library

ManageAccount.dll

FSharp.Core: 3.1.2.5

Target F# runtime: 3.3.1.0

Target Framework: .NET Portable Subset (.Net Framework 4.5, ASP.Net Core 1.0, Windows 8)

Output type: Class Library

I then added the following app config to my test project:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
                          culture="neutral"/>
        <bindingRedirect oldVersion="3.1.2.5" newVersion="3.3.1.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

If I do need an app config, what value should my bindingRedirect be set to?

|improve this question

回答1:


Try <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.3.1.0" />. That's what most F# projects seem to be doing for FSharp.Core. (Or newVersion="4.3.1.0", or even newVersion="4.4.0.0" if you upgrade to a newer FSharp.Core).




回答2:


You should use the newest version (4.3.1.0 in this case) in bindingRedirect/newVersion, otherwise, you will probably get errors from code in Tests.dll assembly which relies on the newer version.

Alternatively you can update the reference in one of the assemblies (downgrade Tests.dll or upgrade ManageAccount.dll) so that they both use the same version.



来源:https://stackoverflow.com/questions/39206991/fsharp-core-could-not-load-file-or-assembly

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