Do you make a strongly-typed wrapper for app.config?
Updated by Brady Stroud [SSW] 1 year ago. See history
123
If your application accesses properties in app.config, you should provide a strongly typed wrapper for the app.config file. The following code shows you how to build a simple wrapper for app.config in an AssemblyConfiguration class:
using System;using System.Configuration;namespace SSW.Northwind.WindowsUI{public sealed class AssemblyConfiguration{// Prevent the class from being constructedprivate AssemblyConfiguration() { }public static string ConnectionString{get{returnConfigurationSettings.AppSettings["ConnectionString"].ToString();}}}}
Unfortunately, the Configuration Block does not automatically provide this wrapper.