"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)!