我想确定构建和安装当前 Mono 运行时的版本(如何在 Git 中正确调用它?)。
$ dmcs --version
Mono C# compiler version 2.9.0.0
但这绝对不够。
XSP/ASP.NET 错误页面提供了更多信息:
Version information: Mono Runtime Version: 2.8.1 (master/cdf1247 Sat Sep 4 01:22:04 MSD 2010); ASP.NET Version: 4.0.30319.1
但这对我来说似乎是一个肮脏的 hack。
如何正确地做到这一点?
最佳答案
如果您正在寻找单声道运行时版本; mscorlib 中有一个内部 Mono.Runtime 类,它有一个静态方法 GetDisplayName,它应该返回一个包含当前运行时版本的字符串。此方法是私有(private)的,但仍然可以通过反射访问。我写了一个小脚本来测试这个,看看是否适合你:
Type type = Type.GetType("Mono.Runtime");
if (type != null)
{
MethodInfo dispalayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
if (dispalayName != null)
Console.WriteLine(dispalayName.Invoke(null, null));
}
在我的系统上返回:
2.6.7 (Debian 2.6.7-3ubuntu1~dhx1)
希望这对你有帮助,问候
关于mono - 如何确定构建和安装当前 Mono 运行时的版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4178129/