你调用的对象是空的。 ? [英] Object reference not set to an instance of an object. ?

查看:73
本文介绍了你调用的对象是空的。 ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个错误调整了网页头...但程序运行,,,锄头隐藏该错误..

this error displed web page head...but program runned,,,hoe to hide that error..

推荐答案

代码中的某个地方,你正在尝试使用包含 null 的变量,就像它包含实际值一样,通过访问它的属性或方法。虽然可以像你提到的那样通过使用 try ... catch 块来隐藏问题,但是就像Tadit和Ian说的那样糟糕。



当代码以这种方式遇到空变量时,它会抛出异常并停止执行代码,然后转到处理程序(如果有的话,如果没有,那么你得到的信息就像你现在一样)。隐藏消息只是意味着你编写的任何代码都不会被执行,除了正确修复错误之外,没有办法让它被执行。



查看错误消息:它会告诉您文件和导致问题的文件中的行号。看看它,看看哪个变量可以为null。如果你不能发现它,那么我们需要看到导致错误的相关代码片段 - 不是整个文件,只是行,并且每边说十或二十行,也许是整个方法。
Somewhere in your code, you are trying to use a variable which contain null as if it contained an actual value, by accessing it''s properties or methods. While it is possible to "hide" the problem as you mentioned by using try...catch blocks effectively, it is as Tadit and Ian have said a bad idea.

When you code meets a null variable in that way, it throws an exception and execution of your code stops, and goes to a handler (if any - if none, then you get a message just like you do now). Hiding the message just means that whatever code you wrote to do sotheing with your page will not be executed, and there is no way to make it be executed other than to fix the error properly.

Look at teh error message: it will tell you a file and the line number in teh file that caused the problem. Look at it, and see which variable could be null. If you can''t spot it, then we need to see the relevant code fragment that causes the error - not the whole file, just the line and say ten or twenty lines each side, maybe the whole method.


当您尝试访问一个null对象的成员时会发生此错误。

如果您可以调试源代码,那么您应该能够解决问题。 />


您可以通过在代码中使用正确的错误处理程序来抑制此错误。

但是,这不是推荐的方法 - 相反,您应该尝试并修复问题。
This error occurs when you try and access a member of an object that is null.
If you can debug your source code, you should be able to solve the problem.

You can suppress this error by using the right error handlers in your code.
However, this is not the recommended approach - rather you should try and fix the problem.


如果数据为空,请检查数据,然后产生这种错误。
please check you data if data is null then this kind of error accrued.


这篇关于你调用的对象是空的。 ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆