Are runtime code contracts compatible w/ ASP.Net?
I'm trying to use code contracts in an ASP.NET app (MVC 3), something simple like:
public class MyController : Controller
{
private readonly MyEntities _db;
public MyController(MyEntities db)
{
Contract.Requires<ArgumentNullException>(db != null);
开发者_开发百科 _db = db;
}
As in project settings:
- Runtime Checking: Full
- Standard Contract Requires
but at runtime, with db equall to null, I don't get an exception. Odd, as the same test in a console does provide the runtime error.
Is there some part of ASP.Net, MVC, or IIS Express that disables the runtime contracts?
Not reproducable with MVC2.
I get parameter exceptions just as expected, running with VS and Cassini.
精彩评论