Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe)..

When you create a new Windows Service project and try to debug it, Visual Studio will show you a Windows Service Start Failure with the message Cannot Start Service from the command line or debugger. A Windows Service must first be installed (using installutil.exe) and then started with the Server Explorer, Windows Services Administrative tool or the NET START command.. The trick my team and I use to workaround this problem, makes use of the service Debug flag. If the Debug flag is on, we just start the service by using our own public Start method. When the OnStart event is fired in the service itself, we call the same public Start method. ...

March 13, 2010 · 1 min · Jef Claes

Webforms lessons learned the hard way (Part 2)

If you missed part 1, you can find it here. Use the built-in goodies ASP.NET Webforms has a lot of good stuff built into it. Do your homework before you start building the next big Webforms thing! A perfect example of this is ASP.NET Membership. ASP.NET provides an out-of-box membership solution. I’ve seen people who were to lazy to do some research or thought they could do better and ended up with a solution which put its doors wide open to people with bad intentions. ...

February 15, 2010 · 2 min · Jef Claes

Webforms lessons learned the hard way (Part 1)

I’ve been spending a lot of my days in Webforms the last two years. In this post I want to share some best practices I’ve learned the hard way over these years. A lot of MVC developers might think this post comes a bit late (who still cares about Webforms?!), I do think (in the real world) a lot of the ASP.NET developers are still using Webforms. This post is directly targeting them. ...

February 14, 2010 · 3 min · Jef Claes

Log4Net: log.Debug(String.Format()) versus log.DebugFormat()

Log4net is one of the most popular opensource logging frameworks available in the .NET world. I’ve been using this framework for over a year now, and today I discovered something new. I often use string.Format() to format my log messages. Earlier this morning I made a typo formatting my message and an Exception was thrown in the beginning of my method which caused the application flow to break. You can avoid this by using the DebugFormat() method. If you mistype here, no exception will be thrown, but a WARN message will be logged. ...

January 20, 2010 · 1 min · Jef Claes

Response.RedirectPermanent in .NET 3.5 and older

One of the new features in ASP.NET 4.0 is permanently redirecting to a page using Response.RedirectPermanent. It is common practice in Web applications to move pages and other content around over time, which can lead to an accumulation of stale links in search engines. In ASP.NET, developers have traditionally handled requests to old URLs by using by using the Response.Redirect method to forward a request to the new URL. However, the Redirect method issues an HTTP 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URLs. ...

December 5, 2009 · 1 min · Jef Claes