ELMAH 1.0 Beta2 to 1.0 Beta3 upgrade gotcha

by Jon Sagara December 11, 2008 at 10:24 PM

In one of my projects, I upgraded ELMAH from 1.0 Beta2 to 1.0 Beta3.  I have 404 filtering turned on so that my log doesn't get flooded with 404 notifications (usually caused by legitimate, albeit a tad overzealous, monitoring applications).  Here is what the Web.config element looks like for Beta2:

<equal binding="HttpStatusCode" value="404" valueType="Int32" />

All of a sudden, when I fired up my site, I started getting a weird error message:

The Empty value type is invalid for a comparison.

It turns out that the XML schema has changed ever so slightly in 1.0 Beta3.  To fix the aforementioned error, you must change the "valueType" attribute to "type", like this:

<equal binding="HttpStatusCode" value="404" type="Int32" />

Hopefully this will save someone some pain. 

Tags: , ,

Blog

Organize Usings

by Jon Sagara August 24, 2008 at 12:09 PM

In Visual Studio 2008, when you add a new Web form to your project, the "using" section of the code-behind contains a lot noise:

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

You may very well need some of those namespace declarations, but odds are high that you don't need them all.  But which ones can you remove without breaking your page?

Visual Studio has a nice feature called Organize Usings, which you access by right-clicking anywhere in the code-behind page.  The menu looks like this:

When you click on "Remove and Sort", it removes any unused "using"s and sorts those that remain. 

So now, instead of the mess that we had before, we have a much cleaner "using" section in our source code file:

using System;

Pretty slick, huh?

Tags: ,

Blog