| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3788 人关注过本帖
标题:“System.NullReferenceException
只看楼主 加入收藏
in羊羊
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-4-17
收藏
 问题点数:0 回复次数:6 
“System.NullReferenceException
代码好像没什么问题,运行时就是这样的提示
我是初学者,现在还是一头雾水呢
谢谢大家帮忙 阿
搜索更多相关主题的帖子: System 一头雾水 提示 代码 
2005-08-03 16:38
in羊羊
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-4-17
收藏
得分:0 

未处理的“System.NullReferenceException”类型的异常出现在 WindowsApplication6.exe 中。

其他信息: 未将对象引用设置到对象的实例。

2005-08-03 16:40
gaofangtao
Rank: 1
等 级:新手上路
帖 子:128
专家分:0
注 册:2005-4-7
收藏
得分:0 
以后写东西要尽量的详细,在一次重申,大家记得啊

我相信我的付出
2005-08-03 21:14
weiy28
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-8-3
收藏
得分:0 
你可以把你的程序放上来给其他人看一下是什么问题的啊!
2005-08-03 21:35
csharp
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-7-22
收藏
得分:0 
可以用MSDN具体查一下是什么原因。
或者对有问题的语句用
try
{
    //Statements
}
catch(Exception err)
{
    Console.WriteLine("{0}", err.Message);
}
察看稍微具体一点的错误原因

喝杯汽酒,交个朋友
2005-08-03 22:52
in羊羊
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-4-17
收藏
得分:0 

private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(8, 40); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(64, 16); this.label1.TabIndex = 0; this.label1.Text = "学号"; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(88, 40); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(104, 21); this.textBox2.TabIndex = 1; this.textBox2.Text = ""; // // groupBox1 // this.groupBox1.Location = new System.Drawing.Point(48, 104); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(192, 120); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "frm"; // // button1 // this.button1.Location = new System.Drawing.Point(104, 80); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(80, 16); this.button1.TabIndex = 3; this.button1.Text = "click me!"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 333); this.Controls.Add(this.button1); this.Controls.Add(this.groupBox1); this.Controls.Add(this.textBox2); this.Controls.Add(this.label1); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false);

}

static int Main(string[] args) { Application.Run(new Form1()); return 0; }

private void button1_Click(object sender, EventArgs evargs) { //textBox2.Text ="click me!"; MessageBox.Show ("hello"); }

private void Form1_Load(object sender, System.EventArgs e) { } }

未处理的“System.NullReferenceException”类型的异常出现在 WindowsApplication6.exe 中。其他信息: 未将对象引用设置到对象的实例。

2005-08-05 10:19
houyunqing
Rank: 1
等 级:新手上路
帖 子:476
专家分:0
注 册:2005-4-1
收藏
得分:0 
你是对一个参考类型的变量进行了操作,然而这个参考变量仅仅是声明了,却没有给它定义一个值,也就是说,那个变量还是null,你就对它进行操作,这样就会导致这个异常
像这样:
class a
{
int x,y;
}
 ...
a  aaa;//仅仅是声明了
aaa.x=10;//这个地方就会出现那样的异常,因为aaa仅仅是声明了,还没有值,还是null

aaa=new a();//为aaa建立内存实体
a.x=10;//OK

寻求挑战,追求完美 Oh,my god!
2005-08-08 09:54
快速回复:“System.NullReferenceException
数据加载中...
 
   



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

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