473,671 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug in Debug.Listeners ?

When I code:
Debug.Assert(fa lse, "this is a message");
it works fine, and out comes the dialog box.

When I code
Trace.Listeners .Clear();
Debug.Assert(fa lse, "this is a message");

No message is output.
In the debugger I see that clearing the Trace Listeners clears the Debug
Listeners. This is a problem since I am using the Trace Listeners for
logging and the debug listeners for debugging. Is this a bug? I am using
C# standard, MDE 2002.
Nov 15 '05 #1
1 1852
Fred Mellender wrote:
When I code:
Debug.Assert(fa lse, "this is a message");
it works fine, and out comes the dialog box.

When I code
Trace.Listeners .Clear();
Debug.Assert(fa lse, "this is a message");

No message is output.
In the debugger I see that clearing the Trace Listeners clears the Debug
Listeners. This is a problem since I am using the Trace Listeners for
logging and the debug listeners for debugging. Is this a bug? I am using
C# standard, MDE 2002.


I don't think MS considers this a bug - the Debug and Trace classes
share the same set of listeners. I agree with you that this should not
be the case. It's a total break of OO encapsulation.

You might want to look into the log4net logging framework.

--
mikeb

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3026
by: chris | last post by:
Hello all - Preface: This isn't a C# Builder question but if you happen to have the answer to my primary problem, please feel free to chime in ;-) I'm using Borland's C# Builder (Personal) and it seems there isn't an Output window (where the Debug.WriteLine() info would go) like VS has. If there is, I can't find it. I would like to know if it is possible to write a class with the ability to call a console window that would display...
0
1414
by: Pete W | last post by:
I have a console application for which I have atttemped to use TextWriterTraceListener. The app uses System.Diagnostic I want to trace or debug to Console and also to file. code in Main() includes: TextWriterTraceListener fw = new TextWriterTraceListener(myFile); TextWriterTraceListener sw = new TextWriterTraceListener(Console.Out); Trace.Listeners.Add(fw); Trace.Listeners.Add(sw);
3
7193
by: Brett | last post by:
I use the following to output to the console during debugging: catch(Exception ex) { Debug.WriteLine("Error: " + ex.Message); } Many of the times on the console, the above is appended on the same line. Sometimes it goes on a new line. I don't have any thing in my code related to trace listeners. Any suggestions as to why this is occuring?
3
21102
by: Frank Rizzo | last post by:
Is there anyway to transparently redirect the output of the Debug.WriteLine statement from the Debug window to something else such as a console or a file? Thanks
4
718
by: A.M | last post by:
Hi, If I use System.Diagnostics.Debug.WriteLine in a asp.net application, where does the output go? Is there any trace monitor application thar shows me the trace output? Thanks, Allan
7
18786
by: Thomas Pecha | last post by:
Sorry for all who think this is easy, I was not able to handle this Coming from VB6 where with simple debug.print strAString you could write to debug window, I am totalling failing in vb.net 2003 The sample in the help file does not work. I tried now for days ... Pls could anybody post a sample, including necessary imports and so on -
1
1167
by: Brian Henry | last post by:
Is there an easy way to make a copy of all the debug.writeline stuff go to a log file also? thanks!
5
3394
by: Billy | last post by:
Hi! How can I override "Debug.Writeline("Message")" so that will not show that msg in Debug window, but wrote it to a file. I already have a code to write to a file but I would like to use just "Debug" class (same name) for that. Inside of that code I will decide if I will wrote that message to debug window or to a file. I would like to use that two options: -Debug.Writeline("Message", 1) '1 is integer argument from 0-9...
1
1543
by: Armin Zingler | last post by:
Hi, I add a TraceListener to Debug.Listeners. After that I use Debug.writeline. Problem: Nothing arrives at the listener. Code: Dim ts As New TraceStream Debug.Listeners.Add(New TextWriterTraceListener(ts))
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8402
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8927
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6237
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.