handling unhandled asp.net exceptions

March 17, 2008

At some point in their career everyone who creates ASP.NET applications has had issues with their site throwing exceptions that aren’t trapped.  We end up displaying a friendly error page at best, and at worst display the yellow ASP.NET error screen of death.  Generally speaking it’s best practice to configure your ASP.NET application to use friendly error pages so that your users aren’t presented with an exception and stack trace that are meaningless to them.

But how do you find out what exceptions are being thrown by users who are not you?  Over the years I’ve created many versions of the same type of code to handle these situations, so last night I created a project on codeplex that I’m calling sigh.net.  Essentially, sigh.net is a provider based unhandled exception handler for ASP.NET applications.  You can download the source at http://www.codeplex.com/sigh.

It’s extremely simple to use and doesn’t require you to change or add any code to your application.  I currently have an email provider created and am in the process of creating a SQL database provider.

Enjoy!


.netSavant rc1 released!

February 23, 2008

I’m proud to announce the release of my new code generating addin, .netSavant.  You can download the release candidate on the website from our download page.

The addin will help you create robust ado.net code with an intuitive drag and drop interface.  Additionally it will generate best practice implementations of three (currently) system interfaces:

  • System.IEquatable<T>
  • System.IDisposable
  • System.ICloneable

Currently I am working on the example code that will help to explain how to best use the ado.net code that is generated.  I’m also working on more and better F.A.Q. entries to answer those pesky little problems that come along with learning a new tool.

If there is any functionality that you’d like to see added to the addin let me know; I’ll entertain any reasonable request.

Enjoy!


visual studio.net 2008 extension methods

January 8, 2008

Now that visual studio.net 2008 has been released developers have a much improved development environment and framework to produce high quality code with.  Extension methods are one of the new framework and IDE features that provides a powerful and clever method of extending objects that you do not have source code for or otherwise can’t directly extend.

Simply put, extension methods allow you to add new methods to the public contract of an existing type without sub-classing, decorating or recompiling the original type.  Prior to this release there were a few options available to solve this problem.

Read the rest of this entry »


formatting source code on wordpress.com

January 1, 2008

I’ve been playing around with the word press features and wanted to post some source code.  For whatever reason it didnt want to format things the way that I wanted and after an hour or so of googling, I found that they’ve implemented a pretty sweet code formatting feature.  To give this a whirl take a look at the code below:


using System;

namespace MagicWebsiteAPI {
    /// <summary>
    /// Provides an interface that specifies a primary key or unique identifier for an object when stored in a storage medium such as a database or file.
    /// </summary>
    /// <typeparam name="TKey">The generic type that represents the type of data that the key is.</typeparam>
    public interface IKeyed<TKey> where TKey : struct {
        /// <summary>
        /// Gets a value that uniquely identifies an instance of the object in a storage medium.
        /// </summary>
        TKey? PrimaryKey { get; }
    }
}

What you’re seeing is an interface that I’ll commonly use in applications that I design.  The interface defines a nullable generic property named PrimaryKey that is typically used to track an objects primary key value in a database.  Its designed as nullable to support new objects that most likely do not have a primary key value assigned to them until after they are persisted to a database.

Additionally, the property is marked with only a get accessor.  Typically I design my objects with static factory methods for object creation (ie, retrieving from the database) which allows me to set the underlying field value without exposing a public set accessor of the property.  I’ll write more about this design pattern in another blog on another day.

Anyway, take a look at the original post that lead me to my first blog entry.