我收到这个错误 [英] Im getting this error

查看:77
本文介绍了我收到这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对象引用未设置为对象的实例.

Object reference not set to an instance of an object.

推荐答案

查找抛出异常的简单方法是

1)进入调试菜单
2)转到例外
3)扩展公共语言运行时异常
4)扩展系统
5)找到system.NullReferenceException并选中throw
下的复选框
运行该应用程序,该应用程序将在引发异常的行上中断.
现在,您拥有找到问题所在的代码行.现在,您可以在这里找到实际的原因.
The easy way to find , where the exception is thrown is

1) Go to Debug Menu
2) Go to Exceptions
3) Expand common Language Runtime Exception
4)Expand System
5) Find system.NullReferenceException and check the checkbox under throw

Run the application, the application will break on the line, where the exception is thrown.
Now you have the line of code where the issue is found. Now from here you can find out the actual cause.


您正在尝试访问的对象成员为null,例如当myPersonObject 本身为null时访问myPersonObject.Age.

通过代码调试可以帮助您了解错误的原因.
You are trying to access a member of an object that is null for e.g. accessing myPersonObject.Age when myPersonObject itself is null.

Debugging through your code will help you understand the cause of the error.


当您尝试访问值为空的对象时,将发生此错误. 调试代码并检查哪个对象变为空.
This error will occur when you try to access a object whose value is null.
Debug the code and check which object is becoming null.


这篇关于我收到这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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