ConfigurationManager.GetSection出错

变成熊猫你就老实了是不 变成熊猫你就老实了是不 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
使用ConfigurationManager.GetSection出错:
出错语句:

Hashtable ht = new Hashtable();
ht = (Hashtable)ConfigurationManager.GetSection("IsLine.AppLog.Configuration/OracleUsingSPRender");
textBox1.Text = ht["AppenderStyle"].ToString();

错误信息:
创建 IsLine.AppLog.Configuration/OracleUsingSPRender 的配置节处理程序时出错: 未能从程序集“System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”中加载类型“IsLine.Data.Configuration.SuitConfig”。
说明:
IsLine.AppLog.Configuration/OracleUsingSPRender 是app.config中的一个节点:
<sectionGroup name="IsLine.AppLog.Configuration">
<section name="OracleUsingSPRender" type="IsLine.Data.Configuration.SuitConfig"/>
</sectionGroup>

<IsLine.AppLog.Configuration>
<OracleUsingSPRender>
<AppenderStyle>Oracle</AppenderStyle>
<AppenderType>StoredProcedure</AppenderType>
<AppenderInf>IsLine.Data.Configuration.OracleConnectString</AppenderInf>
<AppenderContent>SP_ADD_ILFWLOG.ADD_ILFWLOG</AppenderContent>
<LayoutInf></LayoutInf>
<Level>Debug</Level>
</OracleUsingSPRender>
</IsLine.AppLog.Configuration>

IsLine.Data.Configuration.SuitConfig :

namespace IsLine.Data.Configuration
{
public class SuitConfig : IConfigurationSectionHandler
{
object IConfigurationSectionHandler.Create(object parent, object configContext, System.Xml.XmlNode section)
{
Hashtable table = new Hashtable();
foreach (XmlNode xnl in section.ChildNodes)
{
if (xnl.NodeType == XmlNodeType.Element)
{
table.Add(xnl.Name, xnl.InnerText);
}
}
return table;
}
}
}


IsLine.AppLog.Configuration/OracleUsingSPRender运行时会交给IsLine.Data.Configuration.SuitConfig 处理,并返回给ConfigurationManager.GetSection一个Hashtable 。这种用法在B/S中没问题,在C/S中就报错,不知为啥?
...全文
评论 8
收藏 已收藏
分享
返回顶部
变成熊猫你就老实了是不
C# 111,129 成员 642,540 内容