为什么我从config.web文件中读取数据库总是失败
config.web:
<test>
<add key="key" value="just a configure test" />
</test>
test.aspx:
<html>
<head>
<script language="VB" runat=server>
sub page_load(s as object ,e as eventargs)
'取出test配置段的key键的值
Dim CfgSection As Hashtable
CfgSection=New Hashtable
CfgSection=Context.GetConfig("test")
Dim Msg As String = CStr(CfgSection("key"))
lblMsg.text=Msg
end sub
</script>
<title>
配置信息的读取
</title>
</head>
<body>
<center>
config.web中"test"配置段中key的内容为:
<asp:label id=lblmsg runat=server />
</center>
</body>
</html>
为什么我跟着这个应该没有错误的例子做的时候,运行的时候总是提示说是
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
ASP.test_aspx.page_load(Object s, EventArgs e) +98
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724
是不是我的config.web文件的格式不对啊?
可是例子上也是这么写的啊?
请知道原因的高手一定要帮忙啊,小弟感激不尽~~~~