设置System.Console.WindowHeight会在Mono下引发System.NotSupportedException

设置System.Console.WindowHeight会在Mono下引发System.NotSupportedException,exception,mono,console,c#-3.0,window,Exception,Mono,Console,C# 3.0,Window,我得到一个未处理的异常:System.NotSupportedException:操作不受支持。该异常是在Mono下使用Ubuntu11.10引发的 读取属性工作。研究人员可能认为,这种方法不会带来问题 有没有关于如何最好地处理或解决这种情况的想法 我的当前解决方案相当笨拙,无法解决通过System设置窗口大小的问题。Console-API: const int defaultConsoleWindowWidth = 80; const int defaultCo

我得到一个
未处理的异常:System.NotSupportedException:操作不受支持。
该异常是在Mono下使用Ubuntu11.10引发的

读取属性工作。研究人员可能认为,这种方法不会带来问题

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

我的当前解决方案相当笨拙,无法解决通过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)
从:

请注意下面的属性


注意这个属性

好吧,您已经有了一个解决方案。不过,您似乎可以使用Console.setWindowsSize,它不会引发异常,但对不支持该异常的平台(即Windows上的Mono除外)没有任何影响,或者您可以从Mono(linux上使用)扩展TermInfoDriver。好吧,您已经有了解决方案。但是,您似乎可以使用Console.setWindowsSize,它不会引发异常,但对不支持该异常的平台(即Windows上的Mono以外的平台)没有影响,或者您可以从Mono(linux上使用)扩展TermInfoDriver
[MonoLimitation ("Only works on windows")]
public static int WindowHeight {
    get { return ConsoleDriver.WindowHeight; }
        set { ConsoleDriver.WindowHeight = value; }
}