我有一个 .NET4.6.1 项目,如果我链接到 Nuget 的 FSharp.Core 最新版本(在撰写本文时为 4.3.4),则会引发以下异常:
Can't find custom attr constructor image: /Users/andres/Documents/Code/MyApp/src/MyApp/bin/Debug/MyApp.exe mtoken: 0x0a000015 due to: Could not load file or assembly 'FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type: member:
奇怪的是,编译后我只在obj
文件夹中找到了.dll
,而在bin
文件夹中却找不到:
$ find ./src | grep FSharp.Core
./src/MyApp/obj/Debug/FSharp.Core.dll
这是预期的吗?我正在使用 VS4Mac。
最佳答案
事实证明,当将 FSharp.Core nuget 依赖项升级到新版本时,.fsproj 文件中发生的真正差异是这样的:
<Reference Include="FSharp.Core">
- <HintPath>..\..\packages\FSharp.Core.4.1.0.2\lib\net45\FSharp.Core.dll</HintPath>
+ <HintPath>..\..\packages\FSharp.Core.4.3.4\lib\net45\FSharp.Core.dll</HintPath>
+ <Private>False</Private>
</Reference>
(但是看到这一点并不清楚,因为它正在将 <Reference>
标签移动到文件中的其他位置。)
请注意添加 <Private>
上面的标签。如果你这样做what is advised in this other answer to a similar question (我不会声称它是重复的,因为一个是关于 Windows 的,而这个是 macOS),即将引用标记为 LocalCopy=true,然后 Visual Studio 删除 <Private>False</Private>
XML 元素,一切又开始工作。
关于.net - 4.6.1 F# 应用程序抛出 FileNotFoundException : FSharp. 核心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49584528/