运行 在 Linux 上使用 Mono 编译的 F# 程序
Running a compiled F# program with Mono on Linux
我通过
在我的 CentOS 机器上安装了 mono 和 fsharp
$ sudo yum install mono-complete fsharp
并在下面安装了 dotnet 东西
https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos7
我用
编译了我的 Hello World F# 程序
$ fsharpc Program.fs
现在,当我尝试 运行 使用单声道时:
$ mono Program.exe
Can't find custom attr constructor image: /home/gbuday/ion/Program.exe mtoken: 0x0a000005 due to: Could not load file or assembly 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
当我运行这个用
$ dotnet run Program.exe
Hello World from F#!
它运行很顺利。目前尚不清楚 mono 和 dotnet 在此设置中的关系。
我可以 运行 使用单声道编译的 F# 代码吗?我需要什么?
您遇到的问题是 mono 仅与较旧的 F# 语言和核心库兼容,并且由于您没有那个较旧的版本,它会在运行时崩溃。
仅当您今天使用 Xamarin 在 F# 中构建移动应用程序时才需要 Mono。如果您在 Linux 机器上做任何其他事情,我建议您使用 .NET Core 和 .NET CLI 进行所有操作。我建议首先遵循本指南:https://docs.microsoft.com/dotnet/fsharp/get-started/get-started-command-line
您也可以使用稍微简单一些的方法(没有解决方案文件,只有一个项目),但链接的指南将设置一个在实际代码库中常见的文件结构。
我通过
在我的 CentOS 机器上安装了 mono 和 fsharp$ sudo yum install mono-complete fsharp
并在下面安装了 dotnet 东西
https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos7
我用
编译了我的 Hello World F# 程序$ fsharpc Program.fs
现在,当我尝试 运行 使用单声道时:
$ mono Program.exe
Can't find custom attr constructor image: /home/gbuday/ion/Program.exe mtoken: 0x0a000005 due to: Could not load file or assembly 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
当我运行这个用
$ dotnet run Program.exe
Hello World from F#!
它运行很顺利。目前尚不清楚 mono 和 dotnet 在此设置中的关系。
我可以 运行 使用单声道编译的 F# 代码吗?我需要什么?
您遇到的问题是 mono 仅与较旧的 F# 语言和核心库兼容,并且由于您没有那个较旧的版本,它会在运行时崩溃。
仅当您今天使用 Xamarin 在 F# 中构建移动应用程序时才需要 Mono。如果您在 Linux 机器上做任何其他事情,我建议您使用 .NET Core 和 .NET CLI 进行所有操作。我建议首先遵循本指南:https://docs.microsoft.com/dotnet/fsharp/get-started/get-started-command-line
您也可以使用稍微简单一些的方法(没有解决方案文件,只有一个项目),但链接的指南将设置一个在实际代码库中常见的文件结构。