.net - 如何判断我的代码正在 Mono 上运行?

标签 .net mono

这个问题在这里已经有了答案:




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/

相关文章:

c# - CaSTLe Windsor - 控制 transient 组件的创建

c# - 在 Windows 上使用单声道

php - soap 信封是如何生成的,为什么 .NET 和 php 客户端会生成/接收不同的 soap 信封?

c# - 为什么 IQueryable 后面跟着 Any 会导致选择没有Where 子句?

printing - 将 Gtk.Widget 打印到打印机的最佳方法是什么?

c# - 检查 WebException 中的证书验证错误

C 应用程序 (Linux) 的 C# (Mono) 测试意外修改属性

android - 服务堆栈的基本身份验证

c# - 失去焦点后如何保持 NumericUpDown 的无效值?

c# - 这个C#函数组合方法是如何工作的?