我一直在尝试使用此示例中的app.config部分:
它给了我下一个例外:
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>
我不明白为什么......任何人都可以帮忙吗? 谢谢。
答案 0 :(得分:3)
在你的app.config中,检查你是否拥有类ConfigurationCollectionAttribute
的完整命名空间
例如:
<configSections>
<section name="configSectionName"
type="Company.Namespace.ConfigSection, Company.Namespace" />
</configSections>