[Mono-dev] System.Diagnostics.Trace.Write(Line) doesn't seem to work

Sorin Peste neaorin at gmail.com
Sun Oct 15 18:07:13 EDT 2006


Hello,

I'm having a problem trying to use Trace to output messages from my
console application. Basically nothing gets sent out to the trace
listeners; I've tried using both a file and Console.Out and no luck.

This is what I did:

1. created a file Trace.cs and put the following code in it:

using System;

class MainClass
    {
        public static void Main(string[] args)
        {
            using (System.IO.StreamWriter file =
System.IO.File.CreateText("output.txt")) {
                System.Diagnostics.Trace.Listeners.Add(new
System.Diagnostics.TextWriterTraceListener(Console.Out));
                System.Diagnostics.Trace.Listeners.Add(new
System.Diagnostics.TextWriterTraceListener(file));
                System.Diagnostics.Trace.WriteLine("Hello world!");
            }
        }
    }

2. compiled with
    mcs -out:Trace.exe Trace.cs
3. ran with
    mono Trace.exe

No output was sent to the console and the output.txt file is empty. The
same program compiled on Windows .NET produces the correct results.
I'm running mono 1.1.18 installed via SUSE RPMs. I have SUSE 10.1 i386
kernel 2.6.16.
I looked a bit at the relevant source files in SVN HEAD, but i was
unable to spot any problems.
This is my first mail on this list, so I apologize if this has been
posted before. Thank you for any help. If I can provide more
information, or file a bug report, please let me know.

Sorin



More information about the Mono-devel-list mailing list