Tip: Error Handling in .NET

In .NET development the common approach to exception handling is to make use of Try...Catch...Finally.

try {
  // some code
}
catch (NullReferenceException ex)
{
   // handle the exception
}

Sometimes you don't need to handle the exception and you just want to throw it to the calling application

try {
  // some code
}
catch (NullReferenceException ex)
{  
   throw ex;
}

But, if you do that you will get useless messages while debugging your application.

The better approach is to just call throw without "ex"...

try {
  // some code
}
catch (NullReferenceException)
{  
   throw;
}

This now provides the following error message which is much more useful.

Tags:

 

ASP.NET MVC Setup

First things fist... make sure you have the pre-requisites.  Start by removing any previous or beta versions of ASP.NET MVC.  I start with the ASP.NET MVC Downloads page.

Intall the ASP.NET MVC Framework 1.0 - the one you really need is AspNetMVC1.msi

A couple times an issue has come up where the MVC Project Template is not available when you go to New Project.

Double check that you have the project templates at this location...

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033

The MVC Project template is called MvcWebApplicationProjectTemplate.zip

If it is there and you are not getting it as an option try opening the Visual Studio Command Prompt and running the following commands to install the templates:

devenv.exe /installvstemplates
devenv.exe /setup

If you just want the starter project, you can download the following.

MvcStarter.zip (273.24 kb)

Tags:

 

Virtual path maps to another application

I use Web Deployment Projects to build an ASP.NET web site.  

When I built the web project by itself I got a successful build, but the Web Deployment Project received the following error...

The virtual path '/UserControls/Common/ModalProgress.ascx' maps to another application, which is not allowed.

I scratched my head for a few minutes then decided to try adding the ASP.NET root operator "~" in front of the path name.  So, the path became '~/UserControls/Common/ModalProgress.ascx'

After making this change I was able to build my Web Deployment Project.

For more info: Web Deployment Projects and ASP.NET Paths

Tags:

 

What Is Your Standard?

Who sets the standard for what you achieve or accomplish?  Is it you? If you are living to someone else's standard, then what is your standard? 

Living to fill the expectations of others is an empty cause.  Still, we should have a high personal standard for the quality of our work.

Sometimes others have low expectations and we feel so good when we grab that "low hanging fruit".

So the trick is identifying the value of the expectations have of you?  Is it too low?  Then set yours higher.  Is it unrealistically high? Don't get beat down trying to meet lofty expectations.  The key is having the ability to judge the value of the expectations!

Tags: