您的位置:首页 > 编程语言 > ASP

asp.net 异常:Message="Value cannot be null.\r\nParameter name: g"

2009-07-16 15:29 756 查看
ForumTableAdapters.tbTopicTableAdapter topic = new ForumTableAdapters.tbTopicTableAdapter();
Response.Write(Request.QueryString["TopicID"].ToString()); 后来加的测试行
rpt_Topic.DataSource = topic.GetTopic(new Guid(Request.QueryString["TopicID"])); 错误提示所在行
rpt_Topic.DataBind();

错误具体信息

System.ArgumentNullException was unhandled by user code
Message="Value cannot be null.\r\nParameter name: g"
Source="mscorlib"
ParamName="g"
StackTrace:
at System.Guid..ctor(String g)
at ShowTopic.Page_Load(Object sender, EventArgs e) in e:\SOLUTION\Forum\ShowTopic.aspx.cs:line 19
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

上网查了好久,开始以为是iD什么的没写好,然后加断点,就在找g ,因为提示是g为null。最后看看trace,at System.Guid..ctor(String g) ,终于找到g了,所以就是说,new Guid(Request.QueryString["TopicID"]))里面有问题。加了后来加的测试行之后,提示错误在新加的行,确定问题出在Request.QueryString["TopicID"】上。仔细检查代码,终于发现"&TopicID="写成了"&TopicID"少了=,所以提示为null,问题解决。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐