取消处理引用异常 [英] Unhandle Reference Exception
本文介绍了取消处理引用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void validateName_Click(object sender, EventArgs e)
{
if (nameObj.InitializeDataFiles() == mdNAMEOBJECTLib.ProgramStatus.NoError)
{
try
{
File = new StreamReader("../../mdName.sdf");
}
catch (Exception)
{
resultString.Text = "Can't open sample file";
}
while ((FullName = File.ReadLine()) != null)
{
nameObj.ClearProperties();
nameObj.FullName = FullName;
nameObj.Parse();
fullName.Text = FullName;
Records++;
}
}
}
我收到错误消息:mdNameObj.exe中发生了类型为"System.NullReferenceExceiption"的未处理异常.
附加信息:对象引用未设置对象的实例.
如何解决此错误.谢谢,
I got error message:Unhandle exception of type ''System.NullReferenceExceiption'' occured in mdNameObj.exe.
Additional Information: Object reference not set an instance of an object.
How to fix this error. Thanks,
推荐答案
使用调试器找出哪个对象为null,并纠正错误(您没有指出要抛出异常的代码行,因此,我认为您尚未使用调试器).最可能的罪魁祸首是nameObj
和File
(由于它也是.Net命名空间的名称,因此作为变量名很烂).
Use the debugger to find out which object is null, and fix your mistake (you didn''t indcate what line of code was throwing the excveption, so I assume you haven''t used the debugger yet). The most likely culprits arenameObj
andFile
(which sucks as a variable name since it''s also the name of a .Net nameSpace).
这篇关于取消处理引用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文