static LitiumSectionGroup() { Configuration config = null; var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName.StartsWith("System.Web,")); if (assembly != null) { var type = assembly.GetType("System.Web.Configuration.WebConfigurationManager"); var hostingType = assembly.GetType("System.Web.Hosting.HostingEnvironment"); if (type != null && hostingType != null) { var applicationPath = hostingType.GetProperty("ApplicationVirtualPath").GetValue(null, null); if (applicationPath != null) { config = (Configuration)type.InvokeMember("OpenWebConfiguration", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, new[] { applicationPath }); } } } if (config == null) { config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); } _instance = config.GetSectionGroup("litium") as LitiumSectionGroup; }