Home > Backend Development > C#.Net Tutorial > A problem that novices and veterans alike cannot avoid - not setting an object reference to an instance of the object

A problem that novices and veterans alike cannot avoid - not setting an object reference to an instance of the object

黄舟
Release: 2017-02-23 10:09:04
Original
2885 people have browsed it

"The object reference is not set to the instance of the object" I believe that anyone who has written code will encounter this problem regardless of their technical level. What this sentence means is that we did not set the object before referencing the object. initialization. This is usually caused when the object we reference is empty. This problem often occurs when we pass parameters. At this time, we have to consider whether the parameters we call are empty.

The following is the problem I encountered:

I am In the three-tier architecture, the problem that occurred when layer B called the interface, I analyzed that it was because the called interface was not successfully created, because I created the interface through an abstract factory. The error points are as follows:

Classes in the code The name is different from the actual class name. There is an extra 1 in the code here. Although it is a careless mistake, the principle of this error must be clarified. This time it may just be a different class name, but it may not be the same next time. Here are other possible reasons for this error that I found on the Internet. I hope it can be helpful to you.

1. The ViewState object is Null.

2. DateSet is empty.

3. The DataReader is empty due to the SQL statement or Datebase.

4. When declaring a string variable, apply the variable 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 object obtained 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 no preprocessing is done.

10. Repeated definition causes an error that the object reference is not set to the instance of the object.

The above is a problem that both rookies and veterans cannot avoid - not setting the object reference to an instance of the object. More related content Please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template