在 Mono 下设置 System.Console.WindowHeight 会引发 System.NotSupportedException [英] Setting System.Console.WindowHeight throws an System.NotSupportedException under Mono

查看:8
本文介绍了在 Mono 下设置 System.Console.WindowHeight 会引发 System.NotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个 Unhandled Exception: System.NotSupportedException: Operation is not supported. 使用 Ubuntu 11.10 在 Mono 下引发异常.

I get an Unhandled Exception: System.NotSupportedException: Operation is not supported. The Exception is raised under Mono using Ubuntu 11.10.

读取属性有效.docs 可能表明该方法不会造成问题.

Reading the property works. The docs could suggest that the Method does not pose issues.

关于如何最好地处理或解决这种情况的任何想法?

Any ideas on how to best handle or fix this situation?

我的目前的解决方案比较尴尬,并没有解决通过 System.Console-API 设置窗口大小的问题:

My current solution is rather awkward, and does not solve the issue of setting the Window Size through the System.Console-API:

        const int defaultConsoleWindowWidth = 80;
        const int defaultConsoleWindowHeight = 25;


        if (pid != PlatformID.Unix && pid != (PlatformID)128) {
            System.Console.WindowHeight = lastConsoleWindowHeight;
            System.Console.WindowWidth = defaultConsoleWindowWidth;
        }else{
            //assume *NIX system
            try {
                var p = new Process();
                p.StartInfo = new ProcessStartInfo(@"stty cols " + defaultConsoleWindowWidth + " rows " + lastConsoleWindowHeight, "-n")
                {
                    UseShellExecute = false
                };

                p.Start();
                p.WaitForExit();
            }
            catch (Exception e) { /*...*/}


        }

我的单声道版:

lo@lo-VirtualBox:~/Desktop$ mono --version
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS:           __thread
SIGSEGV:       altstack
Notifications: epoll
Architecture:  x86
Disabled:      none
Misc:          softdebug 
LLVM:          supported, not enabled.
GC:            Included Boehm (with typed GC and Parallel Mark)

推荐答案

来自 Github Console.cs 上 mono 的 master 分支:

[MonoLimitation ("Only works on windows")]
public static int WindowHeight {
    get { return ConsoleDriver.WindowHeight; }
        set { ConsoleDriver.WindowHeight = value; }
}

注意 MonoLimitation 属性

Notice the MonoLimitation attribute

这篇关于在 Mono 下设置 System.Console.WindowHeight 会引发 System.NotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆