Do you make a strongly-typed wrapper for app.config?
Last updated by Brady Stroud [SSW] 8 months ago.See historyIf 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 constructed
private AssemblyConfiguration() { }
public static string ConnectionString
{
get
{
return
ConfigurationSettings.AppSettings["ConnectionString"].
ToString();
}
}
}
}
Unfortunately, the Configuration Block does not automatically provide this wrapper.