Debugging a .Net Framework Windows Service and ASP.NET 2.0 version switcher

I don't usually "parrot" other people's contributions, but in this case the solution is so elegant and simple, I'll make an exception.

Lee Humphries has a short article on codeproject.com here about this.

Essentially it boils down to telling your service to kick off and run in Debug mode - just not "as a service":

// The main entry point for the process
static void Main()
#if (!DEBUG)
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service1() };
// debug code: allows the process to run as a non-service
// will kick off the service start point, but never kill it
// shut down the debugger to exit
Service1 service = new Service1();

Man, it doesn't get any simpler than that! Nice work, Lee!

On an unrelated note, Denis Bauer's ASP.NET version switcher works great with ASP.NET 2.0. This is essentially a GUI wrapper over ASPNET_REGIIS.EXE and will make your life much easier. Shows a tree of all your IIS virtual directories including the version highlighted by color in the tree, and allows you to change the version of ASP.NET runtime that the app will run under. Especially useful for Windows Server 2003 x64 edition where I still haven't figured out how to get the ASP.NET tab to show up in IIS as a snapin. Get yours here.

The only thing you need to do now, Denis (if you are listening) is add the option to add the -wow64 switch at the very end, for users running 64-bit Windows.