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

Cedric Vivier cedricv at neonux.com
Sun Oct 15 18:22:01 EDT 2006


Hi!

I just tried on Mono 1.1.17.1 on Linux and no more luck.
The weird thing is that the same code in Boo does work!

C# version :
using System;

class MainClass
   {
       public static void Main()
       {
               System.Diagnostics.Trace.Listeners.Add(new
System.Diagnostics.TextWriterTraceListener(Console.Out));
               System.Diagnostics.Trace.WriteLine("Hello world!");
       }
   }

Outputs: nothing!


Boo version :

import System

System.Diagnostics.Trace.Listeners.Add(
System.Diagnostics.TextWriterTraceListen$
System.Diagnostics.Trace.WriteLine("Hello world!")

Outputs: Hello world!


If you run monodis on the C#-compiled version you will find that there is no
call to Trace.WriteLine at all... so it seems to be more a mcs/gmcs bug than
a runtime/classlib bug.


Regards,


2006/10/16, Sorin Peste <neaorin at gmail.com>:
>
> 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
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061016/d413af90/attachment.html 


More information about the Mono-devel-list mailing list