Klingon Culture on Windows Vista
Mobile Computing

Application Configuration with Libraries

Visual Studio 2005 has a great support to define application- and user-specific configuration with a "Settings" file. Creating a Settings file item, a class is created that derives from the class ApplicationSettingsBase to read application-configuration information from app.config. The values can be read using the strongly-typed class, e.g. Properties.Settings.Default.SomeSetting.

If the application configuration file does not exist, or the configuration information is not found in the file, the default values are hard-coded in the settings-class with the attribute [DefaultSettingValue]. If the values should not be hard-coded, it is possible to disable this feature by setting the property GenerateDefaultValueInCode to false.

Special attention must be taken if the configuration values should be used within a library. With a library it is possible to create a settings file item for strongly typed access to configurations. Of course, libraries don't have their own configuration files. The configuration settings used by the settings class in the library can easily be added to the configuration file of the application.

Special care must be taken if the same configuration values are shared between multiple projects. The tool-generated settings class uses configuration values that include the root namespace of the project. This behavior can be changed by applying the attribute [SettingsGroupName("MyGroup")]. Using this attribute, the group name is used with the configuration file instead of the namespace of the project:

    <setting name="Setting1" serializeAs="String">
      <value>Some value</value>

This makes it possible to share the same configuration between multiple projects although the projects can have different root namespaces.



Feed You can follow this conversation by subscribing to the comment feed for this post.

moncler jackets

oh so funny!

air jordan

Ah! The world is not good.

cheap beats by dr dre sales

cheap beats by dr beats by dre dr beats by dre cheap


It is understandable that money can make us disembarrass. But what to do when someone has no cash? The one way is to try to get the loans and car loan.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)