0

It worked previously within this same project, but doesn't work now. I haven't had any luck with the solutions presented in any related question I could find on this site or elsewhere.

I have written a program to perform some long-running processes, and I have put the code into a solution containing only an mstest project, preferring to avoid any sort of U/I necessity whatsoever. I would like to have some status emitted into the Output window, using code similar to the following:

if (counter % 100 == 0)
{
    Trace.WriteLine(string.Format("Inserted {0} records into {1}.", counter, proprietaryDetails));
}

I am running the tests using the IDE, not the command line. Nothing appears in the Output Window. I cannot set breakpoints on Debug.Write() or Trace.Write() statements when I am debugging.

I have done the following:

  1. Ensured I'm building the project in Debug mode.
  2. Ensured that "Program Output" is checked when I right click the output window
  3. Tried both debugging and running the tests using Ctrl-R + T and Ctrl-R + Ctrl-T.
  4. I have no .config file which might be disabling the default trace listener.

Any help is appreciated. Thanks!

4

1 に答える 1

0

おそらく、次のようなものが役立つでしょうか?

TextWriterTraceListener myWriter = newTextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(myWriter);
Trace.Listeners.Add(myWriter);
于 2012-09-11T20:27:13.370 に答える