设置System.Console.WindowHeight在Mono下抛出System.NotSupportedException [英] Setting System.Console.WindowHeight throws an System.NotSupportedException under Mono

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

问题描述

我收到一个未处理的异常:System.NotSupportedException:不支持操作。异常使用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.

阅读属性有效文档可能表明该方法

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)


推荐答案

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

注意MonoLimitation属性

Notice the MonoLimitation attribute

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

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