SAP Knowledge Base Article - Public

1566187 - Error: ArgumentOutOfRangeException was unhandled when viewing a Crystal Report in a .NET winform application


  • A custom .NET windows application to view the Crystal report throws the following error.

ArgumentOutOfRangeException was unhandled.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

  • The error points to the 'Application.Run(new Form1());' line in the program.cs file of the application.

  • The Crystal report runs fine in the Crystal reports 2008 designer.


  • Visual Studio 2005
  • Crystal Reports 2008, SP3 (report is migrated from Crystal Reports XIR2)


The Crystal report has a formatting formula ( display string ) on a data field of type 'Number', placed in the details section of the report.


Formula :-

 if tonumber ({ Table1.Field1 }) = 0 then 

The Crystal Reports windows form viewer could not render the data passed by the formula at runtime, even when the report works fine in the designer.

The cause of the failure is the null string "", in the 'else' section of the formula.


  • Open the Crystal Report in the Crystal Reports 2008 designer.
  • Right click on the data field go to 'Format Field'.
  • Click on the formula icon in front of 'Display string'.
  • Change the formula to

 if tonumber ({ Table1.Field1 }) = 0 then
    " "  'Use a single space instead of null string here.

  • Save the report in the designer.
  • Add the report to the .Net solution and run the application.


KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


Crystal Reports 2008 V1