I. GENERAL statements on the Internet
1, the ViewState object is null.
2, Dateset 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. Repeatedly defines an instance error that causes the object reference not to be set to an object.
Two
(1) If the variable you set is NULL or has not been given a value, this problem usually occurs when you pass a reference, and it also occurs when using data controls such as the DataGrid or GridView or DataList.
(2) The control name does not correspond to the codebehind inside
(3) object not initialized with new
(4) The control referenced in the program does not exist
Workaround:
(1) Use try: Catch...finally catch error, or output the variable value directly with Response.Write ()
(2) To see if there are uninitialized variables in the code
Three
Sqlconnection.open object reference not set to an instance of an object
Use VS2003 to develop ASP. NET program sometimes occurs when you manipulate the open () method of a SqlConnection object
Object references are not set to an instance of an object.
Description: An unhandled exception occurred during the running of the current WEB request. Check the stack trace information for specific information about the error and the source of the error in your code.
Exception specific information: System.NullReferenceException: Object reference not set to an instance of an object.
SOURCE Error:
。。。。
Conn. Open ();
......
Trace debugging is also sure to be able to determine the new operation of the Conn but the program often makes an error in this place, but sometimes restarting the server or restarting IIS will work. How to debug and can not find the problem then this time may be your local installation of the. NET frameework Framework has a problem, may not have not installed SP1.1 patch
Need to play net FRAMEEWORK1.1 SP1 Patch, to the official Microsoft site download after installation is good.
Four
In general, I have a summary of NullReferenceException anomalies, the following conditions:
1. The namespace in which the object resides is not referenced
2. Object Not instantiated
3, an exception occurs, the instantiation of the failed object is null
Five
The error will also occur when IIS is unable to carry it.
An error occurs when an application has more user access than it can afford.
Improve your programs, use caching, and minimize the number of interactions with your database.
Six
The problem I encountered was that I had no intention of resetting the dataset reference after this problem, please check your own code, is not in other places again reference, in my program DataSet is set as a global object.
Seven
When you find that the whole method is not working, hit the. NETFramework patch
Eight
I have this error, only because the site inside the DAL DLL file invalidation, the business layer can not be instantiated idal inside the object
But also wasted an afternoon on the tune code
Nine
For each suspicious place to join the monitoring, at first thought that the SQL statement was written wrong, checked several times, swapping SQL statements or reported the same error. Based on Google's results, the mention of object redefinition can cause this result. Based on this hint, replace the page-level global object, finally done.
Class dboper{
/* constructor does not have a function body
*
*c# write a series of methods for database operation
*
*
}
Initially for the sake of convenience, as little as possible to declare objects, only in the global declaration of a private Dboper db=new dboper (), in different methods to invoke the method of the object, in order to avoid the definition of the memory waste. Later code refactoring, not error when compiling. When executed, however, "NullReferenceException: Object reference not set to an instance of an object" appears. The result was a couple of hours of doing it. Later, according to Google's results, the different methods used in the Dboper object one by one is defined as a local variable (a method only defines a Dboper object, multiple calls to its methods are normal), remove the global private variable. It's normal to do it again.
The question of why the object that I have defined has been used in a different way by the class is not very clear today .............. .....
Object reference not set to an instance of an object-summary of possible issues