views:

247

answers:

2

Hi,

For some reason, the following line does nothing in my ASP.NET MVC project:

  System.Diagnostics.Debug.Assert(false);

I have triple-checked that I am using the Debug configuration and "Define Debug constant" is checked in the Debug configuration settings.

The same problem also occurs in my unit test project.

Implementing my own assert method seems trivial, but a bit awkward. Any hints on how to fix this would be greatly appreciated.

Edit: I am using several third-party modules in my project. Could this perhaps be caused by referencing a module which is compiled in release mode?

A: 

Since you are running through ASP.NET MVC, could there be a debug=false in your web.config that is causing the problem?

Shiraz Bhaiji
Unfortunately not. I have just checked my web.config and the word debug is only in this line: <compilation tempDirectory="r:\\ASP.NET Temp" debug="true" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspCoverageInstrumenter, Microsoft.VisualStudio.Enterprise.ASPNetHelper, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Adrian Grigore
Also look for whether there's a "system.diagnostics" section in the config file. You can turn off assertions in your config file.
Eric Lippert
@Eric: Thanks for the suggestion, but the word "diagnostics" is not mentioned in my web.config.
Adrian Grigore
@Adrian Grigore have you checked your other configurations for .NET? If you create a simple Console App does it get hit?
Yuriy Faktorovich
+1  A: 

ASP.Net Assertion are displayed in the VS Console while your webpage is displayed through VisualStudio. It doesn't interrupt the thread to display a MsgBox or break to the assertion line like a programming language.