【发布时间】:2019-01-05 05:37:09
【问题描述】:
我正在尝试使用以下代码访问我的“web.config”文件的一部分
public static string XMLCheck
{
get
{
var section = (Hashtable)ConfigurationManager.GetSection("Default.Framework");
return (string)section["ConnectionString"];
}
}
但是被执行为Unable to cast object of type 'System.Configuration.ConfigXmlElement' to type 'System.Collections.Hashtable' 这里有什么问题?如何纠正
?
更新
<Resources>
<Resource Uri="resource:Default:CrossDomain" Version="1.0" Id="8ae96c54" IsEnabled="True" Handler="handler:Default:Framework:Resources:Data:Oracle">
<Properties>
<Property Name="ConnectionString" Value="Data Source=TESTDB;User Id=TESTUSR;password=TESTPWD;Persist Security Info=false"/>
</Properties>
</Resource>
</Resources>
【问题讨论】: