| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4474 人关注过本帖
标题:未将对象引用设置到对象的实例。
只看楼主 加入收藏
七情、六欲
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-1-20
收藏
 问题点数:0 回复次数:8 
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪:


[NullReferenceException: 未将对象引用设置到对象的实例。]
   MasterPage.Page_Load(Object sender, EventArgs e) in D:\桌面\SupermarkeMembertSys\SupermarkeMembertSys\MasterPage.master.cs:13
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 
搜索更多相关主题的帖子: 异常 详细信息 Object 
2013-01-20 12:37
七情、六欲
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-1-20
收藏
得分:0 
请求各位大大帮忙啊 本人小白 不会调试啊
2013-01-20 12:38
七情、六欲
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-1-20
收藏
得分:0 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="SupermarkeMembertSys.login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.

<html xmlns="http://www. >
<head runat="server">
    <title></title>
</head>
<body bottommargin="0" topmargin="0" bgcolor="#14315f">
    <form id="form1" runat="server">
<div align="center">
<table id="Table1" width="1003" height="613" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="8">
            <img src="images/login_01.gif" width="1003" height="2" alt=""></td>
    </tr>
    <tr>
        <td rowspan="5">
            <img src="images/login_02.gif" width="68" height="611" alt=""></td>
        <td rowspan="4">
            <img src="images/login_03.gif" width="23" height="608" alt=""></td>
        <td colspan="5">
            <img src="images/login_04.gif" width="847" height="318" alt=""></td>
        <td rowspan="5">
            <img src="images/login_05.gif" width="65" height="611" alt=""></td>
    </tr>
    <tr>
        <td rowspan="2">
            <img src="images/login_06.gif" width="381" height="84" alt=""></td>
        <td width="162" height="83" rowspan="2" background="images/login_07.gif" class="newStyle1">用户名:<asp:TextBox
                ID="TextBox1" runat="server" Width="101px"></asp:TextBox>
            <br />
            <br />
            密&nbsp;&nbsp;码:<asp:TextBox ID="TextBox2" runat="server" Width="101px"
                TextMode="Password" BorderStyle="None"></asp:TextBox>
            <br />
        </td>
        <td rowspan="2">
            <img src="images/login_08.gif" width="26" height="84" alt=""></td>
        <td width="67" height="39" background="images/login_09.gif">
            <asp:ImageButton ID="ImageButton1" runat="server"
                ImageUrl="~/images/botton1.gif" Height="20px"
                onclick="ImageButton1_Click" />
        </td>
        <td rowspan="2">
            <img src="images/login_10.gif" width="211" height="84" alt=""></td>
    </tr>
    <tr>
        <td width="67" height="45" background="images/login_11.gif">
            <asp:ImageButton ID="ImageButton2" runat="server"
                ImageUrl="~/images/botton2.gif" Height="20px"
                onclick="ImageButton2_Click" />
        </td>
    </tr>
    <tr>   
    <td height="206" colspan="5" align="center" valign="top" background="images/login_12.gif" class="newStyle1">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                           
        验证码:&nbsp;<asp:TextBox ID="TextBox3" runat="server"
            Width="98px"></asp:TextBox>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/AppCode/GetImageCode.aspx" />
                    <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            
            SelectCommand="SELECT [UserID], [UserPassword], [UserType], [UserName] FROM [User] WHERE (([UserName] = @UserName) AND ([UserPassword] = @UserPassword))"
            DataSourceMode="DataReader">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="UserName"
                    PropertyName="Text" />
                <asp:Parameter Name="UserPassword" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
                    <br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
                    <asp:Label ID="Label2" runat="server"></asp:Label>
                    </td>
    </tr>
    <tr>
        <td colspan="6">
            <img src="images/login_13.gif" width="870" height="3" alt=""></td>
    </tr>
</table>
    </div>
    </form>
</body>
</html>
2013-01-20 12:47
七情、六欲
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-1-20
收藏
得分:0 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace SupermarkeMembertSys
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //Session["CheckCode"] = "";
                Response.Cookies.Add(new HttpCookie("CheckCode", ""));
            }

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            //先进行验证码的比较操作
            if ((Request.Cookies["CheckCode"].Value, TextBox3.Text.ToString().Trim(), true) != 0)
            {
                Label2.Text = "验证码错误,请输入正确的验证码。";
                Label2.Visible = true;
                return;
            }
            else
            {
                Label2.Text = "验证码OK。";
                Label2.Visible = true;
                //跟数据库比较用户名密码是否一样
                HttpCookie mycookie;
                string pwd = TextBox2.Text.Trim();
                pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5");
                SqlDataSource1.SelectParameters["UserPassword"].DefaultValue = pwd;
                using (IDataReader mdr = (IDataReader)SqlDataSource1.Select(DataSourceSelectArguments.Empty))
                {
                    if (mdr.Read())
                    {
                        string UserID = mdr[0].ToString();
                        string UserType = mdr[2].ToString();
                        string UserName = mdr[3].ToString();
                        mycookie = new HttpCookie("UserID", UserID);
                        Response.AppendCookie(mycookie);
                        mycookie = new HttpCookie("UserType", UserType);
                        Response.AppendCookie(mycookie);
                        mycookie = new HttpCookie("UserName", UserName);
                        Response.AppendCookie(mycookie);
                        Response.Redirect("Default.aspx");
                    }
                    else
                        Label1.Text = "您输入的密码与用户名不匹配,请重输!";
                }

            }

        }

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
        }
    }
}
2013-01-20 13:59
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:0 
你的母版页有问题..没看到提示吗?  D:\桌面\SupermarkeMembertSys\SupermarkeMembertSys\MasterPage.master.cs:13
这里显示了问题出在母版页的地13行代码!
2013-01-30 11:59
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:0 
应该不是母版页来的.看错了...
2013-01-30 11:59
moridiansha
Rank: 6Rank: 6
来 自:承德
等 级:侠之大者
威 望:4
帖 子:254
专家分:417
注 册:2009-10-21
收藏
得分:0 
.cs文件里,是不是有没实例化或者为空的参数在使用啊?

www.qysy.tk
2013-02-04 11:43
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:0 
你找到母版页那个文件看看就知道啊..(MasterPage.master.cs)
2013-02-05 14:03
moridiansha
Rank: 6Rank: 6
来 自:承德
等 级:侠之大者
威 望:4
帖 子:254
专家分:417
注 册:2009-10-21
收藏
得分:0 
.cs的文件是可以调试的,加断点调试一下,看看在哪出错,然后看看哪个参数的值为空

www.qysy.tk
2013-02-05 15:57
快速回复:未将对象引用设置到对象的实例。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043716 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved