簡體   English   中英

檢查winforms是否可以在單聲道上顯示

[英]Check if winforms can be displayed on mono

我正在制作一個控制台應用程序,該程序在Windows窗體彈出窗口中顯示一些數據,主要用於開發或配置。 但是,在部署時,它將只能在僅命令行的環境中運行,該環境將無法顯示表單。 我想知道是否有一種方法可以檢測是否可以顯示這些表格,以便可以以其他格式顯示數據或在無法顯示數據時打印說明(其中一個表格是圖像)預習)。

是的,先生,對於“單聲道”,我想給您兩個方法:

這會檢查您是否在Mono Runtime中:

private Boolean IsMonoRuntime()
{
      return (Type.GetType("Mono.Runtime") != null);
}

這將為您提供Mono版本(Linux軟件包)或String.Empty:

    private String GetMonoRuntime()
{
    Type type = Type.GetType("Mono.Runtime");

    if (type != null)
    {
        MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
        if (displayName == null)
            return "Unix/Linux + Mono";
        else
            return "Unix/Linux + Mono " + displayName.Invoke(null, null);
    }

    return String.Empty;
}

我希望它的需要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM