using System.Reflection;
using System.Configuration.Internal;
-namespace System.Configuration {
-
+namespace System.Configuration
+{
internal class ClientConfigurationSystem : IInternalConfigSystem
{
- object IInternalConfigSystem.GetSection (string configKey)
+ Configuration cfg;
+
+ public ClientConfigurationSystem ()
{
- Assembly a = Assembly.GetEntryAssembly();
+ }
- Configuration cfg = ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel.None, a, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
- if (cfg == null) return null;
+ private Configuration Configuration {
+ get {
+ if (cfg == null) {
+ Assembly a = Assembly.GetEntryAssembly();
- ConfigurationSection s = cfg.GetSection (configKey);
+ try {
+ cfg = ConfigurationManager.OpenExeConfigurationInternal (
+ ConfigurationUserLevel.None, a, null);
+ } catch (Exception ex) {
+ throw new ConfigurationErrorsException ("Error Initializing the configuration system.", ex);
+ }
+ }
+ return cfg;
+ }
+ }
+
+ object IInternalConfigSystem.GetSection (string configKey)
+ {
+ ConfigurationSection s = Configuration.GetSection (configKey);
return s != null ? s.GetRuntimeObject () : null;
}