Index out of range exception

14 posts, 0 answers
  1. Sukhvinderjeet
    Sukhvinderjeet avatar
    4 posts
    Member since:
    Sep 2015

    Posted 24 Sep 2015 Link to this post

    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

  2. Alena
    Admin
    Alena avatar
    1049 posts

    Posted 24 Sep 2015 Link to this post

    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
  3. Sukhvinderjeet
    Sukhvinderjeet avatar
    4 posts
    Member since:
    Sep 2015

    Posted 28 Sep 2015 in reply to Alena Link to this post

    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";

         
            }
  4. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 30 Sep 2015 Link to this post

    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
  5. Travis Lamkin
    Travis Lamkin avatar
    3 posts
    Member since:
    Feb 2015

    Posted 19 Oct 2015 in reply to Sukhvinderjeet Link to this post

    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

  6. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 21 Oct 2015 Link to this post

    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
  7. Keith
    Keith avatar
    11 posts
    Member since:
    Feb 2016

    Posted 08 Dec 2017 Link to this post

    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.
  8. Alena
    Admin
    Alena avatar
    1049 posts

    Posted 11 Dec 2017 Link to this post

    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
  9. Keith
    Keith avatar
    11 posts
    Member since:
    Feb 2016

    Posted 11 Dec 2017 in reply to Alena Link to this post

    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.
  10. Katia
    Admin
    Katia avatar
    693 posts

    Posted 13 Dec 2017 Link to this post

    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
  11. Keith
    Keith avatar
    11 posts
    Member since:
    Feb 2016

    Posted 13 Dec 2017 in reply to Katia Link to this post

    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.

     

  12. Todor
    Admin
    Todor avatar
    279 posts

    Posted 15 Dec 2017 Link to this post

    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
  13. Ray Jerard
    Ray Jerard avatar
    1 posts
    Member since:
    Jul 2010

    Posted 03 Sep 2018 in reply to Todor Link to this post

    Any update on this matter? 
  14. Alena
    Admin
    Alena avatar
    1049 posts

    Posted 06 Sep 2018 Link to this post

    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
Back to Top