• Uncategorized

About exception : Setting-SystemConsoleWindowHeight-throws-an-SystemNotSupportedException-under-Mono

Question Detail

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?

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) { /*...*/}


        }

My Mono version:

[email protected]:~/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)

Question Answer

From the master branch on mono on Github Console.cs:

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

Notice the MonoLimitation attribute

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.