Tag Archives: errorspotting


Inspired by some of the frustrating experiences we’ve had with technology this year, and to add to our ever-growing DNS footprint, Lauren and I have launched a new blog: errorspotting.com. Our goal is to highlight egregious error messages and experiences in the hope of inspiring (and humiliating) developers and designers to create better user experiences when things go wrong.

We have posted a few items so far, and are eager to include reader contributions to help in our quest to reduce the pain and frustration of users around the world.

ArgumentException: The string must be at least XXX characters long

I hit this obtuse exception the other day. The stack had System.Configuration code on it, which is the only way I managed to track it down to a StringValidator attribute. A few things that would have been helpful:

  1. Having the name of the culprit in the exception string (i.e. The string ‘foo’ must be at least 24 characters long.)
  2. Including the configuration element of which string ‘foo’ is a property of (i.e. The string ‘foo’ must be at least 24 characters long to be used for property ‘bar’ on element ‘baz’.)

Turns out that this was not actually a .config file error. After subclassing StringValidator and creating a ConfigurationValidatorAttribute to bridge into the declarative system, I discovered that the exception was being thrown while validating the default value.

I had naively thought that if you have a required ConfigurationProperty, then you do not need to setup a default value. I was wrong. I discovered that this is a known bug in the .Net Configuration validation framework that has been resolved “By Design”.

I completely understand why they want to run the validators on default values, but the framework really should check if a property is required and suppress default value validation in that case. As it is, the default value is never used, and the framework properly throws an exception if the required property isn’t explicitly set by the user.

As a result, the following is the “correct” way to have a required property that works with the config validation framework:

[ConfigurationProperty(namePropertyName, IsRequired = true,
   // We need to set a default value for our string validator to work 
DefaultValue = "dummy")] 
[StringValidator(MinLength = 1)]
public string Name { … }

Error 1001. The specified service has been marked for deletion

Sometimes I think I should run a signspotting campaign for error messages. In this particular case, the error happens when trying to install or uninstall a Windows service.

Since there was nothing actionable in the error message (sigh), it was off to the web. On MSDN, the only “fix” was to reboot your machine. Boo. Fortunately after digging deeper it turns out that all you really need to do is close services.msc if it’s open.

Given that this is a fairly common situation for services development, hopefully this post will save a few reboots. And maybe the next version of Windows will say something to the effect of “service was unable to install/uninstall because services.msc is open, please close the control panel and retry your installation.”