Skip to Content

Why(!): Object reference not set to an instance of an object error

Purpose

The error "Object reference not set to an instance of an object" is quite uninformative leading to frustrating searches for solutions. In this document we'll take a look at the most common reasons for the error.

Overview

Searching for the error on SCN (search box is in top right corner), I come up with no less that 15 KBAs related to Crystal Reports and Visual Studio .NET. In this Document I do a quick summary / grouping of possible reasons for the error. The 15 KBAs resolve to 6 common groups; from bad coding, to database issues to report design and so on.

Mistakes leading to the error - General

The following are common non Crystal Reports related factors leading to the error:

  1. Not declaring variables.
  2. Use the appropriate scope.
  3. Bad inits/constructs.
  4. "buried" controls.

For more information see the thread Common causes of: Object reference not set to an instance of an object error.

Mistakes leading to the error - Specific to Crystal Reports

  1. Service Packs or updates not applied. A quick search for the error (crystal net Object reference) returns no less than four KBAs specifying the error and resolution being an update for the product. If you are interested, the following KBAs fall into this category; 2022806, 1525822, 1336586, 1544675.
  2. Incorrect runtime deployed, no runtime deployed, incorrect assemblies referenced in the project. Not all versions of Crystal Reports are supported in all versions of Visual Studio .NET. For details see the wiki Which Crystal Reports assembly versions are supported in which versions of Visual Studio .NET. For your reference the following KBAs apply; 1566763, 1836369, 1474515.
  3. Incorrect report design. The error may be thrown if a report object is placed outside the report design pane. Reference KBA 1865556. Other design issues may also cause the error.
  4. Incorrect code, incorrect standards. See KBA 14936191569982, 1664415, 1626917.
  5. Database connectivity issues. Reference KBA 1494929.
  6. Incorrect or invalid use of controls. See KBA 1544651.

Conclusion

Note that the above is not meant to be an exhaustive treatment of all issues leading to the error. No doubt, there are more. And as we discover new reasons for the error, these are documented in our KBA system. New KBAs and other knowledge is tweeted on a daily bases and I invite you to follow us on Twitter:

Crystal Reports for Visual Studio .NET

Other twitter accounts worth following may be:

Crystal Reports Design and Database Connectivity

BI Platform

SAP Dashboards

SAP Lumira

Tags:

No comments