This is a migrated thread and some comments may be shown as answers.

Index out of range exception

14 Answers 220 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sukhvinderjeet
Top achievements
Rank 1
Sukhvinderjeet asked on 24 Sep 2015, 11:53 AM

If I create a report book with 10 pages it works fine.But if I try again with 11 ​pages, It throw exception "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

After deleting all temp files it work for 11 pages

14 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 24 Sep 2015, 03:48 PM
Hello Sukhvinderjeet,

Please share the code which you are using to add reports to the report book and access them. If you are using an integer index to access reports in the ReportBook.Reports collection, make sure that the index is less than the size of the collection.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Sukhvinderjeet
Top achievements
Rank 1
answered on 28 Sep 2015, 08:01 AM
private void SetData(Int32 centerId)
        {
         
            sqlParams.Add(new SqlParameter("@EndDate", Convert.ToDateTime(EndDate)));
            sqlParams.Add(new SqlParameter("@MinCommentDate", Convert.ToDateTime(startDate)));
            DataSet reportBookDataSet = PRSData.FetchDataSet("prs_ReportBook", sqlParams.ToArray(), CommandType.StoredProcedure);

            Int32 page = PRSDataAdapter.GetreferralSourceCount();
            page = (page / 7) + ((page % 7) > 0 ? 1 : 0);

            this.Reports.Add(new CoverPageReport());
            this.Reports[this.Reports.Count - 1].DocumentMapText = "Cover Page";


            for (int i = 1; i <= page; i++)
            {
                this.Reports.Add(new NewPatientsByReferralSourceReports(i));
                this.Reports[this.Reports.Count - 1].DocumentMapText = "New Patients By Referral Source";

            }

            page = PRSDataAdapter.GetEventTypeCount();
            page = (page / 3) + ((page % 3) > 0 ? 1 : 0);
            for (int i = 1; i <= page; i++)
            {
                this.Reports.Add(new ProcedureActivityTrendAnalysisReport(i));
                this.Reports[this.Reports.Count - 1].DocumentMapText = "Procedure Activity Trend Analysis";

            }

            this.Reports.Add(new ProcedureBillingTrendAnalysisReport());
            this.Reports[this.Reports.Count - 1].DocumentMapText = "Procedure Billings Trend Analysis";

     
        }
0
Stef
Telerik team
answered on 30 Sep 2015, 03:17 PM
Hello Sukhvinderjeet,

The issue is not reproducible with the provided code snippet. We will need a runnable demo project to test it locally.

Please debug the application to determine what causes the error. As you mentioned that deleting some temp files resolves the problem, please elaborate in what context you are running the code for generating the ReportBook, and what temp files you refer to.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Travis Lamkin
Top achievements
Rank 1
answered on 19 Oct 2015, 01:26 PM

We are seeing similar behavior after upgrading our version of Telerik Reporting.  Were you able to determine the cause and implement a fix to the issue?

Regards,
Travis

0
Stef
Telerik team
answered on 21 Oct 2015, 04:31 PM
Hi Travis,

We are currently investigating the issue based on the provided by you project, but the scenario is not correctly set. The mechanism used for changing the ReportBook object produces different ReportBook objects on each call of the resolver, and initially there are 3 calls for registering the client, the instance and obtaining parameters - on each of these calls the ReportBook object must be the same, and the counter in your examples changes the content.

We will appreciate it if we continue the discussion in your support thread on the same question. If  anyone experiencing the same problem has a demo project, please open a support ticket and send it to us for further tests.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Keith
Top achievements
Rank 1
answered on 08 Dec 2017, 03:58 PM
I would like to resurrect this thread because I am experiencing the same issue.  Is there is a resolution to this issue?  If not, I am able to duplicate it with just a few lines of code to the ReportBook example/demo code released with the latest version of Reporting.
0
Nasko
Telerik team
answered on 11 Dec 2017, 08:17 AM
Hello Keith,

Please send us the code and where to place it to reproduce the issue. Alternatively, you can open a new support ticket and provide us a sample project.

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Keith
Top achievements
Rank 1
answered on 11 Dec 2017, 03:40 PM
The only file I changed was ReportBook.cs in the ReportLibrary.

As Stef mentioned, “initially there are 3 calls for registering the client, the instance and obtaining parameters - on each of these calls the ReportBook object must be the same.”  I verified this by determining the AddReports method was called 3 times for each ReportBook generation.

So, I created a static variable just above the ReportBook constructor and initialized it to 0.  See image01.jpg.  The highlighted code is what was added.

Then, at the end of the AddReports method, I added an if statement that would add another report for each of the 3 calls to AddReports every other time the ReportBook is generated.  See image02.jpg.  The highlighted code is what was added.

In other words, the first, third, fifth, etc. time the ReportBook is generated the extra report is NOT added and ReportBook example/demo performs as it should.  However, the second, fourth, sixth, etc. time the ReportBook is generated, the Index out of Range Exception occurs.
0
Katia
Telerik team
answered on 13 Dec 2017, 02:42 PM
Hi Keith,

This behavior is related to the service storage. Initially, the report document (ReportBook with n number of reports) is saved in the storage. As the report source doesn't change the storage retrieves the same document instance every time until it expires. When one more report is added to ReportBook.ReportSources, the same document will still be retrieved from its storage which will cause an error due to a different number of reports in ReportBook.ReportSources collection.

Let us know how exactly the reports are added to a ReportBook in your actual project.
 

Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Keith
Top achievements
Rank 1
answered on 13 Dec 2017, 04:15 PM

Hi Katia,

This issue is just now arising for us because we have to meet a new requirement of running in an Azure, load balanced environment.  Instead of trying to move to that environment with the obsolete ReportViewer, we decided the time to upgrade to the HTML5 ReportViewer was long overdue.

We have an accounting software application, which has 300+ existing reports/sub-reports, all of which were created with the Visual Studio report designer, having the .cs extension.  Essentially, we allow our customers to configure what they want to see in a report.  Based on what they configure, we add individual reports to a ReportBook.  This method works fine with the obsolete ReportViewer.  Now that we have upgraded to the HTML5 ReportViewer, we are seeing these issues.

A specific example is our General Ledger’s Detail Ledger report, where customers can select which funds in the account structure to report on.  Because each fund can have N number of departments, which can also have N number of accounts, the report on one fund can span several pages.  For this type of report, we put each fund’s report in a ReportBook, which allows the customer to use the document map to quickly navigate between funds.  Again, this method works fine with the obsolete ReportViewer.

If I’m understanding you correctly, it seems that once any ReportBook is generated, no other ReportBook can be generated until after the previous one expires.  This seems quite restrictive.  I would think that because, as you say, a ReportBook can have N number of reports in its collection, each generation of a ReportBook might need to be considered unique.

I will be more than happy to work with anyone on your end to come to a resolution for this, as moving to an Azure, load balanced environment is a high priority for us.

 

0
Todor
Telerik team
answered on 15 Dec 2017, 02:51 PM
Hello Keith,

I have opened a new support ticket on your behalf. We would continue resolving the particular case in this ticket.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ray Jerard
Top achievements
Rank 1
answered on 04 Sep 2018, 02:56 AM
Any update on this matter? 
0
Nasko
Telerik team
answered on 06 Sep 2018, 08:18 AM
Hello Ray,

The issue was resolved by stopping the report book caching when it is required to change the report book at run-time.

This is an excerpt from my reply in the support thread:

"There is an approach which will force the report book to be generated anew each time it is requested. This should prevent any caching of the report book and any index out of range exceptions. Each document in the cache is identified by its report name (type name or URI) and its parameter values. To stop the report book caching, all you need to do is pass a unique value to a parameter in the report book each time you request to view the report book. This value can be the current date and time, or it could be a new GUID."

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
anon
Top achievements
Rank 1
Iron
answered on 04 Aug 2021, 07:35 AM
Hi, I'm getting the same error when I choose my test db in Oracle (its a big database having lots of tables and views etc.) and selecting the Query Designer. It just waits at "Loading database metadata" and gives error stating "Index was out of range. Must be non-negative and less than the size of the collection. parameter name: index".
Neli
Telerik team
commented on 09 Aug 2021, 08:34 AM

If I understood correctly, the problem is reproducible when you click on the Query Builder in the Standalone designer. I would recommend attaching a Trace Listener as explained in the Standalone Report Designer Problems article. Once the log is generated, you can send it to us, so we can inspect it locally.
Tags
General Discussions
Asked by
Sukhvinderjeet
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Sukhvinderjeet
Top achievements
Rank 1
Stef
Telerik team
Travis Lamkin
Top achievements
Rank 1
Keith
Top achievements
Rank 1
Katia
Telerik team
Todor
Telerik team
Ray Jerard
Top achievements
Rank 1
anon
Top achievements
Rank 1
Iron
Share this question
or