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

  • Home
  • SEARCH
  • 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 8624435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:31:42+00:00 2026-06-12T07:31:42+00:00

We have a bunch of .NET assertions throughout our code, which we never see

  • 0

We have a bunch of .NET assertions throughout our code, which we never see fail. If for some reason an assertion did fail, we would rather terminate the process and generate a crash dump than corrupt our users’ data.

We have all the architecture set up to create a memory dump upon an unhandled exception, so we would like our Assertions to behave that way in a release build. Is there a way of doing this neatly, or do we just need to replace all our Assert calls with some other function that asserts and then throws?

  • 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-06-12T07:31:43+00:00Added an answer on June 12, 2026 at 7:31 am

    One option is to use Trace.Assert instead of Debug.Assert.

    From the Remarks section of the MSDN page:

    Use the Trace.Assert method if you want to do assertions in release builds. The Debug.Assert method works only in debug builds.

    EDIT: In response to the comment:

    The reason for the existence of Trace.Assert is to give the same functionality as Debug.Assert but in production builds. You should be able to use the same infrastructure that you use for crash dumps on Debug.Assert, but you’ll have to reference Trace instead of Debug. From the MSDN article Assertions in Managed Code:

    For example, you could override the TraceListener.Fail method to write to an event log instead of displaying the Assertion Failed dialog box.

    In your case, you could probably reuse the same TraceListener that you are (probably – I don’t know unless you say so) using today to generate a crash dump. The only difference is that you’d add it to Trace.Listeners instead of Debug.Listeners.

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

Sidebar

Related Questions

I have a .net assembly that contains data access code (a bunch of Typed
I have bunch of strings, some of which are fairly long, like so: movie.titles
I have a bunch of code here -- http://jsfiddle.net/gDX3d/ A nice guy helped me
So currently in our code, we have a bunch of classes around accessing roles
I have a bunch of old VB.NET code, written originally on VS2005, and now
I have a bunch of text boxes in my ASP.NET MVC view which are
Possible Duplicate: Compiling C code for .NET I have a bunch of C source
Note: This is .NET regular expressions. I have a bunch of text, from which
I have a bunch of nested ASP.net repeaters, which each generate table structures when
I have a bunch of custom attributes in my .NET application and I would

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.