How to determine the revision from which current Mono runtime was built and installed?

烈酒焚心 提交于 2019-12-22 14:53:12

问题


I want to determine the revision (how to call properly it in Git?) from which current Mono runtime was built and installed.

$ dmcs --version
Mono C# compiler version 2.9.0.0

but it's definitely insufficient.

XSP/ASP.NET error page gives more information:

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

but it seems to be a dirty hack to me.

How to do it properly?


回答1:


mono -V will output the version string, including source code revision.




回答2:


If you're looking for the mono runtime version; there is an internal Mono.Runtime class in mscorlib, it has a static method GetDisplayName which should return a string with current runtime version. This method is private but still can be accessed via reflection. I wrote a small script to test this, check if would work for you:

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)); 
}

on my system this returns:

2.6.7 (Debian 2.6.7-3ubuntu1~dhx1)

hope this helps, regards



来源:https://stackoverflow.com/questions/4178129/how-to-determine-the-revision-from-which-current-mono-runtime-was-built-and-inst

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!