Question

I am trying to add assert statements to a project, but they keep being skipped. Is there an option I need to enable somewhere?

The assert statement is:

Debug.Assert(false, "Deserialization failed", "Deserialization failed");

And I am running in debug mode. I could be doing something silly; I am not sure.

Was it helpful?

Solution

Make sure the DEBUG conditional compilation symbol is defined. In VS2008 that's on the project's property page on the Build tab: "Define DEBUG constant". This should be the case by default for a debug build, but it's possible that it got switched off.

It may be set/unset in similar but different ways in other IDEs (possibly with an edit control instead of a checkbox).

It's also possible (but rather unlikely) that it is being disabled by a configuration file setting, either with an <assert assertuienabled="false" /> setting or because the DefaultTraceListener has been removed from the Listeners collection. See the documentation for the Debug.Assert() method for more details if you think this might be what's going on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top