Kevin Hazzard's Blog Has Moved
Posted on 2/11/2008
I started using a new blogging engine in February 2008. The posts I made before the move are still here. But you should check out my new blog at this address instead:
http://www.gotnet.biz/Blog
Windows Services Can Install Themselves
Posted on 11/23/2007
Using the InstallUtil.exe utility that ships with the .NET SDK can be a real pain. It's rarely in the PATH so you probably have to hunt down the utility when your working on QA and production servers as I do. Installing a Windows Service should be easier. In this short article, I'll show you a way to make your Windows Services install themselves without needing InstallUtil.exe at all.
Using Fiddler2 Web Debugging Proxy with Firefox
Posted on 7/26/2007
Here's a cool tip. You can use Microsoft’s amazing Fiddler2 Web Debugging Proxy with Firefox and other browsers, not just Internet Explorer. Fiddler2 doesn’t work with Firefox automatically as it does with IE, but it can be made automatic without a lot of work. Jump to the bottom of this article if you just want the facts. If you want to know how it works, read on.
Dynamically Generating Sitemaps Using 404 Errors
Posted on 7/22/2007
Using Microsoft Internet Information Server (IIS), when you designate a page to handle HTTP 404 (Not Found) errors on a website, you don’t have to return an HTTP 404 error at all. Instead, you can build dynamic content and return it with an HTTP 200 (OK) result instead. This is helpful when you want to build a sitemap.xml file to enhance the search engine performance for your website. In this article, I’ll show you how I did this for the gotnet.biz site.
Introduction to Spring.NET Factories and AOP
Posted on 7/17/2007
Aspect-Oriented Programming (AOP) is cooler than the iPhone. I know it's hard to believe but it's just the truth. For the uninitiated, AOP is probably best described as software modularization taken to a whole new level. The Spring.NET framework has some fantastic AOP functionality built right in to facilitate Inversion of Control (IoC) through several very powerful object factory patterns. In this first of several articles exploring Spring.NET, let's examine how object factories are used to make Spring.NET's AOP and IoC containers really simple and powerful for solving everyday programming problems.
Making Your Website a Bit More SEO Friendly
Posted on 7/10/2007
I won't pretend to know everything there is to know about Search Engine Optimization or SEO. Nowadays, just keeping up with google's changes to their search engine technology is a full-time job. Among the low-hanging SEO fruit is one simple idea: if your page names are descriptive, most search engine bots will index them. This article explains how to implement the IHttpModule interface to create virtual, SEO-friendly web pages on your ASP.NET website.
Dynamically Emitting an Enumerated Type at Runtime
Posted on 7/3/2007
A co-worker asked me the other day if there were a way to build an enumerated type dynamically at runtime. He had an interesting problem. He wanted to be able to read a database table at startup and create an enumerated type from one of the columns in the result. Here's one way to do that. I wrote a helper method called CreateEnumType which you can adapt to your needs.
Digging Deep on Casting Generics in .NET
Posted on 6/26/2007
Things don't always work as you might expect when you go about casting one .NET data type to another. This is especially true with the generic collections because they are strongly-typed. When you cast a generic collection, you're asking the compiler to assert that the outer type (the container) is a match and that the inner type (the values contained within the collection) also match. In this article, we'll use various debugging tools to take a deep look at what at first glance appears to be a simple casting problem.
Testing References for Null-ness
Posted on 6/19/2007
Other programmers who read my code often ask, "Kevin, why do you cast references to the type System.Object before you test to see if they are null?" People who know me also know that I don’t do anything without a good reason. And there is a good reason to cast references to type Object before comparing for null-ness.
A Generic Property Sorter
Posted on 6/12/2007
When I switched to C# after nearly 18 years of coding with C++, I missed a few things. Templates were one of those features that I found hard to live without. As a C++ programmer, I used the Standard Template Library (STL) a lot. And I wrote a lot of my own generic algorithms and classes using C++ templates. So when I started using C# in 2001, it felt odd not to have a templating mechanism in my language. I didn't get all of the capabilities of templates back with C# generics, but it's close enough. In this article, I'll show how to implement an IComparer<T> algorithm that uses reflection to sort a collection of objects based on property names.