使用VS 2017时无法解析对程序集FSharp.Core 4.4.1.0的依赖关系 [英] Cannot resolve dependency to assembly FSharp.Core 4.4.1.0 when using VS 2017

查看:75
本文介绍了使用VS 2017时无法解析对程序集FSharp.Core 4.4.1.0的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在VS 2015和F#4.0(4.4.0.0)中进行了一段时间的开发.

I have been developing in VS 2015 and F# 4.0 (4.4.0.0) for quite some time.

随着VS 2017的发布,我想在最新的VS中打开用于开发工作的解决方案,但仍有一段时间将项目保留为VS 2015,F#4.0,.NET 4.5.2.构建服务器还必须使用VS 2015一段时间.

With the release of VS 2017, I want to open solutions in the newest VS for development work, but still for a while keep the projects as VS 2015, F# 4.0, .NET 4.5.2. The build server will also have to use VS 2015 for a while.

据我所知,这种情况在早期VS版本升级中没有问题,但是那时我不认为我使用了F#.

As far as I can remember, this kind of scenario has not been problematic in earlier VS version upgrades, but then I don't think I used F# at that time.

我打开了解决方案并尝试进行编译.我在C#应用程序项目中收到此错误. (还有其他C#应用程序,并且至少有一个引用了F#库.)

I opened the solution and tried to compile. I get this error in a C# application project. (There are other C# applications, and at least one references an F# library.)

未知的生成错误,无法解析对程序集的依赖" FSharp.Core,版本= 4.4.1.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a",因为尚未预加载.使用ReflectionOnly API时,必须通过ReflectionOnlyAssemblyResolve事件预加载或根据需要加载相关程序集.

我在解决方案中的所有F#项目均为4.0(4.4.0.0).我仔细检查了.

All my F# projects in the solution are 4.0 (4.4.0.0). I double checked.

为什么会这样?

推荐答案

我搜索了"4.4.1.0",发现C#项目的"obj"文件夹中有一个与应用程序不同的.exe.config文件. .config.它具有不在项目的app.config中的这些额外信息.

I searched for "4.4.1.0", and discovered that the "obj" folder of the C# project had a .exe.config file that differed from the app.config. It had this extra information that is not in the app.config of the project.

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

为什么会自动附加它,为什么只在这个特定的C#项目中?

Why is this appended automatically, and why only in this particular C# project?

我试图将该部分复制到项目的app.config中,并在两个地方都将其更改为4.4.0.0,但这没有用.还尝试使用"4.4.1.0"作为旧版本的上限,并使用"4.4.0.0"作为新版本,但是仍然无法正常工作.相同的编译器错误.

I tried to copy that section to the app.config of the project, and change it to 4.4.0.0 in both places, but that didn't work. Also tried to use "4.4.1.0" as upper limit of old version, and have "4.4.0.0" as new version, but still didn't work. Same compiler error.

然后,我删除了该部分,并在C#项目中引用了FSharp.Core 4.4.0.0.终于摆脱了编译错误.

Then I removed that section, and I referenced FSharp.Core 4.4.0.0 in the C# project. That finally got rid of the compile error.

我运行了程序.它因此异常而崩溃.

The I ran the program. It crashed with this exception.

未处理的异常:无法加载文件或程序集'FSharp.Core,版本= 4.4.1.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040)

我通过重定向重新插入了该部分,现在程序运行正常.

I reinserted the section with the redirect, and now the program runs fine.

总结一下,我添加了对FSharp.Core 4.0的引用,重定向看起来像这样

Just to sum up, I added a reference to FSharp.Core 4.0, and the redirect looks like this

<bindingRedirect oldVersion="0.0.0.0-4.4.1.0" newVersion="4.4.0.0" />

进行了这些修改后,该解决方案在VS 2015中仍然可以按预期运行.

With these modifications, the solution still works as expected also in VS 2015.

这篇关于使用VS 2017时无法解析对程序集FSharp.Core 4.4.1.0的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆