Object reference not set to instance of object--problem record
Source: Internet
Author: User
Today (7/23/07) morning for a few hours, non-stop debugging, or no point.
For each suspicious place to add monitoring, at first thought it was the SQL statement was wrong, checked several times, to exchange SQL statements or reported the same error. According to the results from Google, the reference to object redefinition can cause such a result. According to this hint, replace the page-level global object, finally finished.
Class dboper{
/* constructor has no function body
*
*c# write a series of methods to manipulate the database
*
*
}
Initially for the sake of convenience, as little as possible to declare the object, only in the global declaration of a private Dboper db=new dboper (), in different ways to invoke the object's method, to avoid the definition of a waste of memory. Later, the code refactoring, in the compile time did not error. But when it is run, "NullReferenceException: An object reference is not set to an instance of an object" appears. The result was a couple of hours of it. Later, according to Google's results, the different methods used in the Dboper object one by one to redefine the local variable (a method that only defines a Dboper object, multiple calls its methods are normal), remove the global private variable. It's normal to run again.
As for why it is not clear how to make a custom object into class for private use in different ways, it is not yet obvious ....... ...........
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.