// methods and properties

        private XmlDocument LoadConfigurationFile(
            string configurationFile,
            SchemaLoader schemaLoader,
            string schemaNamespace)
        {
            using (XmlTextReader textReader = new XmlTextReader(configurationFile))
            {
                XmlReaderSettings validatingReaderSettings = new XmlReaderSettings();
                validatingReaderSettings.ValidationType = ValidationType.Schema;
                validatingReaderSettings.Schemas.Add(schemaLoader.LoadSchemaSet());

                using (XmlReader validatingReader = XmlReader.Create(textReader, validatingReaderSettings))
                {
                    XmlDocument document = new XmlDocument(new NameTable());
                    document.Load(validatingReader);

                    if (document.DocumentElement.NamespaceURI != schemaNamespace)
                    {
                        throw CreateConfigurationException(
                                  "The namespace '{0}' of the root element is invalid. Expected namespace: '{1}'.",
                                  document.DocumentElement.NamespaceURI, schemaNamespace);
                    }

                    return(document);
                }
            }
        }