如何检测其.NET运行库正在使用(MS与单声道)? [英] How to detect which .NET runtime is being used (MS vs. Mono)?

查看:169
本文介绍了如何检测其.NET运行库正在使用(MS与单声道)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个程序是否正在使用单声道运行时或Microsoft运行时执行的执行过程中就知道了。

I would like to know during execution of a program whether it is being executed using the Mono runtime or the Microsoft runtime.

我目前使用以下code,以确定我是否在MS CLR:

I'm currently using the following code to determine whether I'm on a MS CLR:

static bool IsMicrosoftCLR()
{
    return RuntimeEnvironment.GetRuntimeDirectory().Contains("Microsoft");
}

然而,这一定程度上取决于运行时的安装文件夹,我不知道这是否会在所有安装工作。

However, this is somewhat dependent on the installation folder of the runtime and I'm not sure whether this will work on all installations.

有没有更好的方法来检查当前运行时?

Is there a better way to check for the current runtime?

推荐答案

从Mono项目的指南移植的WinForms应用的:

public static bool IsRunningOnMono ()
{
    return Type.GetType ("Mono.Runtime") != null;
}

我敢肯定你会有很多更多的问题,所以值得检查本指南和单论坛

这篇关于如何检测其.NET运行库正在使用(MS与单声道)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆