可能重复:
How to detect which .NET runtime is being used (MS vs. Mono)?如何告诉我的代码在Mono上运行?
在.NET道琼斯我怎么知道我的代码在运行单?
可能重复:
How to detect which .NET runtime is being used (MS vs. Mono)?如何告诉我的代码在Mono上运行?
在.NET道琼斯我怎么知道我的代码在运行单?
从单FAQ:
http://www.mono-project.com/FAQ:_Technical
下面是直接从该链接:
我怎样才能检测是否是在运行单?
具有依赖于底层运行时的代码被认为是 错误的编码风格,但有时候这样的代码对于解决运行时错误是必需的。检测单声道所支持的方式是:
using System;
class Program {
static void Main()
{
Type t = Type.GetType ("Mono.Runtime");
if (t != null)
Console.WriteLine ("You are running with the Mono VM");
else
Console.WriteLine ("You are running something else");
}
}
任何其他劈,如检查的基础类型System.Int32 的或其他corlib类型,注定在未来失败。
长和短,只是不。
public static bool IsRunningOnMono()
{
return Type.GetType ("Mono.Runtime") != null;
}
(我被告知添加评论,对不起)检查color = D(我知道这是厚脸皮,但是meh) – Coops