app.config创建和阅读部分麻烦

时间:2011-09-08 11:34:55

标签: .net app-config

我一直在尝试使用此示例中的app.config部分:

http://msdn.microsoft.com/en-us/library/system.configuration.configurationcollectionattribute.aspx#Y2391

它给了我下一个例外:

An error occurred creating the configuration section handler for MyUrls: Could not load file or assembly 'ConfigurationCollectionAttribute, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. (E:\Projects\AppConfigSectionsTesting\AppConfigSectionsTesting\bin\Debug\AppConfigSectionsTesting.vshost.exe.Config line 4)

这是配置文件 -

   <?xml version="1.0" encoding="utf-8" ?>
<configuration>

 <configSections>
   <section name="MyFolders" type="FoldersSection, 
      ConfigurationCollectionAttribute, Version=1.0.0.0, Culture=neutral,   PublicKeyToken=null" />
</configSections>
<MyFolders>
   <Folders>
    <add Path ="D:\\RUN"/>
</Folders>
</MyFolders>

 </configuration>

我不明白为什么......任何人都可以帮忙吗? 谢谢。

1 个答案:

答案 0 :(得分:3)

在你的app.config中,检查你是否拥有类ConfigurationCollectionAttribute的完整命名空间

例如:

<configSections>
    <section name="configSectionName"
             type="Company.Namespace.ConfigSection, Company.Namespace" />
</configSections>