What should dictate when I should use the configurationManager.AppSettings or the strongly typed settings that visual studio generates? The strongly typed ones seem much more appropriate in most cases, but I suppose that it would be possible to add settings dynamically to a deployed application using the ConfigurationManager approach, but are there any guidelines under which circumstances each is designed to be used?
views:
502answers:
3
A:
I'd advise that the loosely typed settings are older and really should only be used for backwards compatibility.
The strongly-typed settings are more robust as they are... strongly typed.
Jeremy McGee
2009-12-16 12:19:21
+2
A:
From what I read, looks like AppSettings is the older way of doing things. MSDN docs states that user settings can be written at run time if you are using settings.
I always prefer strongly typed settings, which can be implemented with ConfigSection handlers.
ram
2009-12-16 12:23:09
thanks, that question was what I was looking for when I was searching.
Sam Holder
2009-12-16 12:31:43
A:
Use Properties.Settings.Default.SettingName. But ConfigurationManager.AppSettings[”SettingName”] should be used only when first is impossible to use.
Vasiliy Borovyak
2009-12-16 12:23:18
please explain under what circumstances the first might be impossible to use?
Sam Holder
2009-12-16 12:28:49
If Properties.Settings.Default is used in another assembly. For example if Settings belong to assembly MyMainApplication and it uses MyBusinessLogicLibrary, - in this case MyBusinessLogicLibrary can only access `ApplicationSettingsBase` methods.
Vasiliy Borovyak
2009-12-16 14:45:41