ConfigurationManager.GetSection出错

使用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中就报错,不知为啥?
...全文
1272 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangkuang5 2009-05-15
  • 打赏
  • 举报
回复
1.app.config 要在winform的exe项目里
2.Configuration config = ConfigurationManager.OpenExeConfiguration(path);
(Hashtable)config.GetSection["mySection"]
chenchangxiong 2009-05-15
  • 打赏
  • 举报
回复
<section name="OracleUsingSPRender" type="IsLine.Data.Configuration.SuitConfig"/>
指定SuitConfig这个类的所在的Assembly,比如说Test
<section name="OracleUsingSPRender" type="IsLine.Data.Configuration.SuitConfig, Test"/>
  • 打赏
  • 举报
回复
d
  • 打赏
  • 举报
回复
没解决
悔说话的哑巴 2009-05-08
  • 打赏
  • 举报
回复
是你.AppLog.Configuration这里出了问题,重新编译一下。
PENYY 2009-05-07
  • 打赏
  • 举报
回复
重新生成一下app.config
wuyq11 2009-05-07
  • 打赏
  • 举报
回复
没有引用相关的DLL,重新生成看看
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
(Hashtable)config.GetSection["mySection"]
蓝海D鱼 2009-05-07
  • 打赏
  • 举报
回复
up

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧