Found an interesting trap when configuring settings for a screensaver I’m working on. In Visual Studio, you can configure Settings for your project - there’s a dedicated page of project properties just for this purpose:

Visual Studio Settings

The whole mechanism is pretty seamless - user settings are automatically stored as an XML file located in the users profile, and you (the developer) don’t have to deal with finding special folder names and building paths and so on.

What isn’t totally clear at first glance is that you aren’t limited to the standard set of data types:

Visual Studio Settings

At the bottom of the list, you can select Browse and enter the name of any class you like.

Tonight though, I kept getting this error message as I tried to configure my Settings:

Visual Studio Settings

This, despite clearly having the required class as a part of my project …

namespace mandelbrot
{
    public class ScreenSaverSetting
    {
        public string Name { get; private set; }
 
        public ScreenSaverSetting(string name)
        {
            Name = name;
        }
    }
}

Have you spotted the problem?

The message “Type ‘mandelbrot.ScreenSaverSetting’ is not defined” is misleading, for the problem isn’t that the class is missing, the problem is that for a class to be used for settings, it must have a parameter-less constructor. As soon as I modified the class appropriately, everything went just fine.

Comments

blog comments powered by Disqus
Next Post
NAnt Naming  22 Apr 2008
Prior Post
Git  15 Apr 2008
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
April 2008
2008