donderdag 24 maart 2011

VS2010 Settings not updating

Nitty gritty detail, could drive you mad.

In Visual Studio 2010 I have a C# Windows application. I changed the connectionstring for the database in the app.config file. Later, I opened the Properties | Settings. VS noticed that the app.config had changed and suggested to change the settings accordingly. Yes, VS, I would like that, thank you. 

But then (as it turned out much later), it does NOT change the default setting in the Settings.Designer.cs, in the

[global::System.Configuration.DefaultSettingValueAttribute(....)]

When you simply run the application, it will read app.config (or actually the values that were copied to <applicationname>.exe.config). But when you - a I did - use it's classes from a Test project, it will only use the default setting.

Solution: open the editor in the Properties | Settings designer, test your connection (if you want to), and then save the setting. Now VS sees that you altered it, and adjusts the .cs file accordingly.