我一直在尝试通过以下示例处理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>
我不明白为什么...。有人可以帮助吗?
谢谢。
最佳答案
在您的app.config中,检查是否具有类ConfigurationCollectionAttribute
的完整名称空间
例如:
<configSections>
<section name="configSectionName"
type="Company.Namespace.ConfigSection, Company.Namespace" />
</configSections>