You have not set the object reference to the instance of the object. NullReferenceException, nullpointerexception not handled
During the reconstruction of the data center, various problems were encountered, including the following: "The object is not set to the instance of the object", for example:
This problem is really common and tangled. In particular, many people next to me have encountered this problem during this time. After debugging for many days, I cannot find a solution. It is really a torment.
So what is the problem with this error? In fact, there are many reasons for this. Let me talk about the situation.
1. No new initialization object is used.
When defining an object class or a layer, you sometimes forget to add new
2. The name is incorrect.
Sometimes we will rename the class, but forget to regenerate the solution or have generated but do not know why the saved file is inconsistent with the class name in the program, this will also cause this problem. Another kind of naming error exists in the program, because the name in the Code is not re-generated, resulting in inconsistency and error.
This error is common in the factory, reflection, and configuration files. Many people have encountered this problem. Note: First, check whether your class names are inconsistent because they are renamed (especially layer D). Second, the characters in the factory are spliced to be consistent with the names of related classes in the D Layer. Third, check whether the names of files in the SAVE path are consistent with the interrupt names of the programs; fourth, if you use a configuration file, you must note that the class name of layer D must contain the characters you set in the configuration file, as shown below:
3. The control property is not set.
This problem occurs when I export an Excel file. I display the returned data in the DataGridView control. The data displayed at the beginning is successful and no error occurs, however, this problem occurs during the combined query. Fortunately, I have read a blog from Shijie before. The solution to this problem is to set the allowUserToAddRows attribute of the control to False.
This is one of the several types of problems I have encountered. Of course, there are still many reasons for such problems. I hope these methods can bring you ideas. We also hope that our partners who have other problems and solutions will give their ideas, discuss them together, and make common progress.