[英]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.