简体   繁体   中英

Problem loading Configuration

I try to load a System.Configuration.Configuration from a configuration-File that is stored on another location (other disk). But iam getting the following...

Exception: An error occurred creating the configuration section handler for SectionName: Could not load file or assembly 'Assembly' or one of its dependencies.

            FileStream fileStream = new FileStream(@"c:\fancyFile.xml", FileMode.CreateNew);
            fileStream.Write(MyProject.Resources.Resource, 0, MyProject.Resources.Resource.Length);
            fileStream.Close();

            System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(@"c:\fancyFile.xml");
            MyProject.Configuration conf = MyProject.Configuration.GetConfiguration(@"c:\fancyFile.xml").GetSection("MySection") as MyProject.Configuration;

  <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
          <section name="MySection" type="MyProject.Configuration, MyProject" allowLocation="true" allowDefinition="Everywhere"  />
      </configSections>
<MySection>

我只能推测您要加载的配置文件具有一个带有/configuration/configSections/section @type属性的/configuration/configSections/section ,该属性引用了不在您的应用程序bin文件夹中的某些程序集。

It sounds as though the configuration specifies an assembly name of 'Assembly'. This is probably not correct. It would be helpful if you could post the contents of the c:\\fancyFile.xml file so that we can check this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM