[Mono-dev] Possible problem with Console in 1.1.18

Susan Mackay susanmackay at optusnet.com.au
Fri Oct 20 08:02:12 EDT 2006


(MacBook Pro, Intel processors, OS X V10.4.8, Mono 1.1.18 from the
MonoFramework-1.1.18_0.macos10.novell.x86.dmg distribution image)

I wrote the following trivial program:


================================
using System;

namespace InstallTest
{
    public class InstallTest
    {
        public static void Main()
        {
            // Insert your code here
            Console.WriteLine( "Goodbye, Forever!");
            return;
        }
    }
}
===============================

When I tried to use gmcs to compile and then use Mono to run this (actually
within the Xcode environment on OS X which simply creates a sub-process
attached to a pseudo-terminal) I get the following errors:

=================================
Unhandled Exception: System.TypeInitializationException: An exception was
thrown by the type initializer for System.Console --->
System.NullReferenceException: Object reference not set to an instance of an
object
  at System.TermInfoDriver.Init () [0x00000]
  at System.ConsoleDriver.Init () [0x00000]
  at System.Console..cctor () [0x00000] --- End of inner exception stack
trace ---

  at <0x00000> <unknown method>
  at InstallTest.InstallTest.Main () [0x00000]


==================================

I also wrote the following test program:

====================
using System;
using System.Diagnostics;

namespace RunTest
{
    public class RunTest
    {
        public static int Main()
        {
            Process proc = new Process();
            proc.StartInfo.FileName = "/usr/bin/Mono";
            proc.StartInfo.Arguments = "InstallTest.exe";
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = false;
            proc.Start();
            proc.WaitForExit();
            return 4;
        }
    }
}
=====================

which returns the same error message but followed by the "...has exited with
status 4" message, which indicates the error message is coming from the
sub-process. If I comment out the 'Start()' and 'WaitForExit()' lines the
program runs and returns the exit status of '4' as expected.

Also if I compile with mcs instead of gmcs, then I get the expected
behaviour from the original program.

When I try this from the 'standard' terminal emulator I get the expected
output in all situations.

I note that the release notes state that a new Console module was added that
was supposed to fix problems with redirection. (By the way, the original
program code worked fine under 1.1.17 with both mcs and gmcs)

Is this a bug?

Thanks

Susan





More information about the Mono-devel-list mailing list