1

This program can work on debug mode but can't work on release mode:

 static void Main(string[] args)
    {
        Trace.Listeners.Add(new TextWriterTraceListener(@"c:\prog\a.txt"));
        Debug.AutoFlush = true;
        Debug.WriteLine("abc");
        Debug.Close();
    }

When this program run in release mode,it can work without error,but can't write line "abc" in a.txt Can you teach me why?Thanks

wang kai
  • 1,673
  • 3
  • 12
  • 21

1 Answers1

1

Because you are using

Debug.WriteLine("abc")

Which will not compile when building in release mode, use instead :

Trace.WriteLine("abc")

Note also that Trace wil execute on both modes of building.

Ali Ezzat Odeh
  • 2,093
  • 1
  • 17
  • 17