如何解决无法加载文件或程序集“FSharp.Core”
我正在尝试将一个程序从 IL 编译为 GNU/Linux 上的 exe,但无法解释如何动态链接 FSharp.Core.dll
。我尝试将其复制并粘贴到构建 .exe 的同一目录中,但没有成功。我实际上不确定问题出在哪里:在我的 .il 代码中、在我的两个 JSON 文件中或在环境中。
$ dotnet --list-sdks
5.0.301 [/usr/share/dotnet/sdk]
我使用 /usr/bin/ilasm testRepeat.il
编译并使用 /usr/bin/dotnet ./testRepeat.exe
运行它。编译输出表示自动添加对 FSharp.Core 的引用
$ /usr/bin/ilasm testRepeat.il
Assembling 'testRepeat.il',no listing file,to exe --> 'testRepeat.exe'
testRepeat.il : Warning -- Reference to undeclared extern assembly 'System.Runtime',adding.
testRepeat.il : Warning -- Reference to undeclared extern assembly 'FSharp.Core',adding.
testRepeat.il : Warning -- Reference to undeclared extern assembly 'System.Private.CoreLib',adding.
testRepeat.il : Warning -- Reference to undeclared extern assembly 'System.Console',adding.
Operation completed successfully
$ dotnet ./testRepeat.exe
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null'. The system cannot find the file specified.
File name: 'FSharp.Core,PublicKeyToken=null'
[1] 140195 IOT instruction (core dumped) dotnet ./testRepeat.exe
解决方法
看起来所有依赖项都应该在“...deps.json”文件中提及。我需要添加以下内容才能使其工作:
{
...
"targets": {
...
"FSharp.Core/5.0.0": {
"runtime": {
"lib/netstandard2.0/FSharp.Core.dll": {
"assemblyVersion": "5.0.0.0","fileVersion": "5.0.20.50704"
}
}
}
}
},...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。