示例#1
0
        /// <summary>
        /// Gets the config file URL.
        /// </summary>
        /// <returns></returns>
        private static AuthenticationConfigurationSection GetAuthenticationConfigurationSection()
        {
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
            Assembly asm = Assembly.GetCallingAssembly();
            Uri      uri = new Uri(Path.GetDirectoryName(asm.CodeBase));

            fileMap.ExeConfigFilename = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + "pluggin.dll.config"; //Path.Combine(uri.LocalPath, "pluggin.dll.config");
            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            AuthenticationConfigurationSection authConfigurationSection =
                config.GetSectionGroup("SomeSectionGroupName").Sections["AuthenticationSection"] as
                AuthenticationConfigurationSection;

            if (authConfigurationSection == null)
            {
                throw new NotSupportedException();
            }

            return(authConfigurationSection);
        }