A problem that neither rookie nor veteran can avoid--object references are not set to an instance of an object

Source: Internet
Author: User
"Object reference not set to an instance of an object" I believe that the problem is that whenever you write a code, regardless of the technical level you encounter, it means that we did not initialize the object before referencing the object. This is usually caused by the fact that the object we are referencing is empty. This is often the case when we pass parameters, and we will consider whether the arguments we call are empty.

Here are some of the problems I have encountered:

I was a problem when I called the interface in layer three, and I analyzed it because the interface that was called was not created successfully because I created the interface through an abstract factory. The error points are as follows:

The name of the class in the code is different from the actual class name, there is a 1 more in the code, although it is a careless mistake, but also to clarify the principle of this error. This time may be just the class name is different, next time not necessarily, below is I found from the Internet other possible causes of this error, I hope you can help.

1, the ViewState object is null.

2, Dateset is empty.

3, the SQL statement or datebase cause DataReader empty.

4. When declaring a string variable, the variable is applied without assigning a null value.

5. The object is not initialized with new.

6. The Session object is empty.

7. When assigning a text value to a control, the value does not exist.

8. When using Request.QueryString (), the obtained object does not exist, or the initial value is not assigned when the value is empty.

9, when using FindControl, the control does not exist but does not do preprocessing.

10. Duplicate definition causes the object reference not to be set to the object's instance error.

These are the problems that both novices and veteran birds cannot avoid--not setting object references to the contents of an instance of an object, more about topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.