这个问题在这里已经有了答案:
9年前关闭。
Possible Duplicate:
How to detect which .NET runtime is being used (MS vs. Mono)?
在 .net 中,我如何判断我的代码是否在 Mono 上运行?
最佳答案
来自 Mono 常见问题解答:
http://www.mono-project.com/FAQ:_Technical
以下直接来自该链接:
How can I detect if am running in Mono?
Having code that depends on the underlying runtime is considered to be bad coding style, but sometimes such code is necessary to work around runtime bugs. The supported way of detecting Mono is:
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");
}
}
Any other hack, such as checking the underlying type of System.Int32 or of other corlib types, is doomed to fail in the future.
长短不一,只是不要。
关于.net - 如何判断我的代码正在 Mono 上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7077576/