cody said:
Why not? Are there disadvantages?
Because TRACE is defined in Release builds by VS.NET. The default trace
listener will generate trace messages that write to the
OutputDebugStream. This writes the data to a memory mapped file
protected by two events. The code that reads output debug strings
controls whether the writing process can write the strings by setting
these events. If the reading process says the writing process cannot
write, then the thread in the writing process is *blocked*. (There is a
timeout, IIRC it is a second). The point is that a process reading the
output debug stream controls whether writer threads in *all* processes
on your machine can be blocked.
My opinion is that as the developer of the code I don't want some other
process to affect my application's performance. Yes, you can use the
config file to remove the default trace listener, but how do you know
that the people who use your code won't alter the config file? (Deleting
the config file will enable the default trace listener.)
Also the default trace listener implements Assert as a modal dialog, so
if you've got any Trace.Asserts in your code, these will work in Release
mode. This means that when your application dies just before it goes you
give your customer a nice dialog saying that you thought it might die,
and here's the reason why! Not particularly good PR, especially since it
appears as if you are using your customers to do your QA. And a modal
dialog blocks the thread, so the process will not die immediately, which
can be a real pain if the process is a service running under a
non-interactive account because you won't see the dialog! (Years ago I
was bitten by this - I used a library written by Oracle in a service and
this library would ocassionally put up a modal dialog indicating that I
had called code that should be there, but they hadn't written yet, and
this would block my service thread!)
Also, call me a secretive if you like, but I really don't want my
customers to see my debug information. <g>
Richard