简体   繁体   English

在运行时如何确定使用哪个单声道版本?

[英]At runtime how does one determine which mono version is being used?

On a system multiple mono runtime versions may exist. 在系统上,可能存在多个Mono运行时版本。 For example 例如

/usr/bin/mono
/usr/local/bin/mono

When creating a new managed process from a C# application it can be useful to be explicit about which mono version you want to run it with. 从C#应用程序创建新的托管流程时,明确说明要与之一起运行的单声道版本可能很有用。 (The mono in the path may not be the mono being used to run the current process) (路径中的单声道可能不是用于运行当前进程的单声道)

Using the Process class to get the current process name returns the assembly that mono is running not mono itself. 使用Process类获取当前进程名称将返回Mono正在运行的程序集,而不是Mono本身。

What is the best way to determine which mono runtime is currently being used? 确定当前正在使用哪个Mono运行时的最佳方法是什么?

On Linux, the process Id and /proc can be used to find the mono executable. 在Linux上,可以使用进程ID和/proc查找单可执行文件。

string monopath = String.Format("/proc/{0}/exe", Process.GetCurrentProcess().Id);

monopath will be a symlink to the current executing mono runtime, and can be used to launch a new process: monopath将是当前正在执行的Mono运行时的符号链接,可用于启动新进程:

Process.Start(monopath);

You can use 您可以使用

    Type monoRuntimeType;
    MethodInfo getDisplayNameMethod;
    if ((monoRuntimeType = typeof(object).Assembly.GetType("Mono.Runtime")) != null &&
        (getDisplayNameMethod = monoRuntimeType.GetMethod("GetDisplayName",
          BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding, null,
                  Type.EmptyTypes, null)) != null)

    Console.WriteLine("Mono " + (string)getDisplayNameMethod.Invoke(null, null));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM