我使用app.config文件来存储凭据,当我试图检索它们时,我得到一个TypeLoadException,如下所示:
无法从程序集“System.Configuration、Version=4.0.0.0、Culture=neutral、PublicKeyToken=b03f5f7f11d50a3a”加载类型的Culture=neutral
这是一个.NET 4.5项目,我将System和System.Configuration Copy-Local属性设置为true,我不知道问题是从哪里来的。我对.NET编程没有经验,所以不太容易理解组装的概念。
下面是代码片段:
app.config
<configSections>
<sectionGroup name="Credentials">
<section name="Twitter" type="System.Configuration.DictionarySectionHandler"/>
</sectionGroup>
</configSections>
<Credentials>
<Twitter>
<add key="****" value="*****"/>
<add key="****" value="*****"/>
</Twitter>
</Credentials>连接服务文件
var hashtable = (Hashtable)ConfigurationManager.GetSection("Credentials/Twitter");我知道这是个常见的问题,我在发帖子之前就搜索过了。但到目前为止,我找到的所有解决方案似乎都不起作用,或者我可能还没有正确理解它们。
提前谢谢你。
发布于 2017-01-22 19:46:55
关于msdn文档,您需要像汉斯所说的那样在app.config中使用Fully qualified class name。在你的代码中
<sectionGroup name="Credentials">
<section name="Twitter" type="System.Configuration.DictionarySectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</sectionGroup>https://stackoverflow.com/questions/21826982
复制相似问题