views:

554

answers:

1

I am trying to add assert statements to a project but they keep being skiped 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 not sure.

+1  A: 

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.

Michael Burr