Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 794859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:22:58+00:00 2026-05-14T22:22:58+00:00

I have a couple of libraries which use Debug.Assert(…) . I think that the

  • 0

I have a couple of libraries which use Debug.Assert(...). I think that the Debug.Assert(...) are fine and I still want them to execute, but I don’t want them to block the execution of my application. Ideally, I would only like them to be logged somewhere.

Given that I can’t change the code of the libraries (and that I still want to compile in debug and run the assertion), how do I prevent Debug.Assert(...) to show a modal dialog?

In addition, I would like to make sure that the main program continues when an Assert occurs (same behavior as the Ignore button).

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:22:59+00:00Added an answer on May 14, 2026 at 10:22 pm

    I wouldn’t recommend it. The problem is that Debug.Assert is only supposed to be fired when you have bugs in your code. If you just ignore them or don’t fix them, then you are doing your users a disservice. If, on the other hand, you’re firing Debug.Assert for things that aren’t bugs, then you’re also doing your users a disservice (by reducing the impact of Debug.Assert).

    Having said that, you can disable it. The first thing you need to do is remove the default listener from the Debug.Listeners collection:

    Debug.Listeners.Clear();
    

    Then, add your own instead:

    Debug.Listeners.Add(new MyTraceListener());
    

    You need to create a class that inherits from TraceListener:

    class MyTraceListener : TraceListener
    {
        // ...
    
        public override void Fail(string msg, string detailedMsg)
        {
            // log the message (don't display a MessageBox)
        }
    }
    

    The important method is the TraceListener.Fail method, which in the implementation of DefaultTraceListener is what displays the message box.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of libraries that use code similar to the following one.
I have a asp.net mvc site that references a couple of libraries. Recently I
I have a couple of internal libraries which I haven't/don't know how to add
I have a couple of Javascript libraries of my own that do some nice
I have a couple of document libraries that are just standard libraries - no
I have .NET service (C#) that uses a couple of c++ libraries. I have
We have some nightly build machines that have the cuda libraries installed, but which
I have a couple of libraries that are created using avr-ar. Each contains a
I have couple of hyperlinks on my website. What I want is to remove
I have couple of dozen pieces of data that I need to save and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.