Crystal Reports Exception: The maximum report processing jobs limit configured by your system administrator has been reached
Asked Answered
T

12

14

I'm facing a very buggy issue, in ASP.NET application after viewing the same report many times simultaneously I got this exception:

The maximum report processing jobs limit configured by your system administrator has been reached.

I know there are tons of solutions out there but all of them are not working with me.

  1. I put ReportDocument.Close(); ReportDocument.Dispose(); in CrystalReportViewer_Unload event, and still throw the exception.
Private Sub CrystalReportViewer1_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Unload
    reportFile.Close()
    reportFile.Dispose()
    GC.Collect()
End Sub
  1. I edit the PrintJobLimit registry in HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\InprocServer and HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\Server to -1 even to 9999, and still throw the exception.

Here is the code snippet where I call my report:

                    Table_Infos = New TableLogOnInfos()
                    Table_Info = New TableLogOnInfo()
                    Con_Info = New ConnectionInfo()
    
                    With Con_Info
                        .ServerName = ConfigurationManager.AppSettings("server_name")
                        .DatabaseName = ConfigurationManager.AppSettings("DB")
                        .UserID = user_name
                        .Password = pass_word
                        .Type = ConnectionInfoType.SQL
                        .IntegratedSecurity = False
                    End With
    
                    Table_Info.ConnectionInfo = Con_Info
    
                    If Session("recpt_lang") = "Arabic" Then
                        reportFile.Load(Server.MapPath("/Reports/") & "collectrecpt_new_ar.rpt")
                    ElseIf Session("recpt_lang") = "English" Then
                        reportFile.Load(Server.MapPath("/Reports/") & "collectrecpt_new.rpt")
                    End If
    
                    For Each mytable In reportFile.Database.Tables
    
                        mytable.ApplyLogOnInfo(Table_Info)
    
                    Next
    
                    CrystalReportViewer1.ReportSource = reportFile
                    CrystalReportViewer1.SelectionFormula = Session("SelectionForumla")
                    CrystalReportViewer1 = Nothing
Trommel answered 6/3, 2012 at 8:4 Comment(0)
S
12

I would recommend moving your close/dispose/gc.collect code outside of that unload process. In other words:

  1. Load report
  2. Assign to Viewer Control
  3. Show Report in Viewer Control
  4. Close Viewer Control and Unload (completely)
  5. Then close/dispose/gc.collect outside of any viewer control code

My guess is the viewer control is not completely closed when the report is being cleaned up.

Crystal is a very memory intensive process and very finicky.

Stairs answered 6/3, 2012 at 15:58 Comment(2)
I am also trying to do the same by using...but that shows object reference type exception, so I have to use unload method which doesnt look good.Wessex
can you please post here the complete code of all these 5 points.Insolvency
U
24

You have to Dispose your report instance after all. If you Dispose the report after showing it, you will never see the error "The maximum report processing jobs limit configured by your system administrator has been reached" again.

  Dim report1 As rptBill = clsBill.GetReport(billNumber)

  rpt.Print()

  'Cleanup the report after that!
  rpt.Close()
  rpt.Dispose()
Underglaze answered 6/3, 2012 at 16:12 Comment(0)
S
12

I would recommend moving your close/dispose/gc.collect code outside of that unload process. In other words:

  1. Load report
  2. Assign to Viewer Control
  3. Show Report in Viewer Control
  4. Close Viewer Control and Unload (completely)
  5. Then close/dispose/gc.collect outside of any viewer control code

My guess is the viewer control is not completely closed when the report is being cleaned up.

Crystal is a very memory intensive process and very finicky.

Stairs answered 6/3, 2012 at 15:58 Comment(2)
I am also trying to do the same by using...but that shows object reference type exception, so I have to use unload method which doesnt look good.Wessex
can you please post here the complete code of all these 5 points.Insolvency
F
6

Crystal Report document implements IDisposable interface. So all you have to do is to enclose the report's instance with using statement. It will be automatically closed and disposed once the using statement is completed. You can write something like that:

using(var report = GetInvoiceReport())
{
     // your logic here
}

or (depends on your context):

using(var report = new ReportDocument())
{
     // your logic here
}
Flair answered 17/6, 2016 at 18:50 Comment(0)
P
4

Make sure you are using PUSH model to display your reports. Next you have to make one change in your Server's registry: Follow the path:

"HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\InprocServer" 

and you will see an item " PrintJobLimit" and you will see that its default value is 75. that means the server can only handle 75 reports at a time. Dont worry about that and just modify the value to -1

Plainsman answered 24/3, 2015 at 12:6 Comment(2)
Please @Plainsman check my question I wrote that I already done that.Trommel
You are essentially making the print jobs unlimited. this is very very bad practice. Might as well tell them to restart IIS every time it happens and you'll be fine.Deuteragonist
D
3

Greetings I am too late to have answer on it, all reply are working and i have seen but in case still you are facing same problem and error then please once go in to TEMP folder under "windows" directory and delete all instances of crystal report. I am saying this because all above option will work but you are still in the maximum reach so first of all delete all instance then apply all the above suggestion. thanks

Duty answered 15/12, 2015 at 11:18 Comment(0)
I
2

I was working on local report server. I have hosted my web application in other pc. When I got such error I just did IISRESET and working fine now.

Try this, this could help you.

Isar answered 2/3, 2016 at 11:45 Comment(0)
A
2

Make sure IIS user have sufficient permission to delete files present in "c:/windows/temp" folder.

I face the same issue once I provide write permission to that folder then it solved my issue.Also make sure dispose that object after generating the file

Accuse answered 18/1, 2018 at 4:45 Comment(1)
If the IIS user has permission to create the files in temp, why would it not have permission to delete them afterwards?Diplomatics
H
1

You have to Dispose your report instance after all. If you Dispose the report after showing it, you will never see the error:

The maximum report processing jobs limit configured by your system administrator has been reached

Code:

Dim report1 As rptBill = clsBill.GetReport(billNumber)

rpt.Print()

'Cleanup the report after that!
rpt.Close()
rpt.Dispose()
Heparin answered 10/4, 2017 at 11:16 Comment(0)
D
1

In my case, the report had 4 subreports...

What solved for me was changing the value of "PrintJobLimit", from 75 to 500, in the following Regedit paths:

  • \HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\InprocServer

  • \HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\Server

Dairying answered 2/6, 2018 at 18:24 Comment(1)
This solution worked for my client-only Crystal Report viewer WinForm application. I only had to change the "Server" version. I just changed it to 500 and voila. My application does not leak memory or slow down over time. It's the viewer control that has this idiotic limitation.Sarraute
S
1

I know this thread is older, but if you configure the app pool setting "Recycling..." to recycle at, say, 180 minutes instead of 1740 minutes (the default), this might free up the needed resources.

Sellingplater answered 14/1, 2019 at 17:10 Comment(0)
S
1

Use These methods when unload the page

    ReportDocument crystalReport;
    protected void Page_Unload(object sender, EventArgs e)
    {
        if (crystalReport != null)
        {
            crystalReport.Close();
            crystalReport.Dispose();
        }
    }

OR

        protected void Page_Unload(object sender, EventArgs e)
    {
        if (crystalReport != null)
        {
            crystalReport.Close();
            crystalReport.Clone();
            crystalReport.Dispose();
            crystalReport = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
    }
Somniferous answered 29/11, 2021 at 7:21 Comment(0)
B
0

I ended up using GC.WaitForPendingFinalizers in addition to the GC.Collect, close and dispose. I believe my web page was perhaps unloading and stopping thread processing prematurely before the garbage was properly processed (really?)

This is on Server 2012, SQL 2012, CR 13.0.2000.0

Here's my code:

#Region "Cleanup"

Private Sub crCleanup(Optional blnForce As Boolean = False)
    Try
        ' Crystal(code Is Not managed, i.e.it) 's COM interop => you have to manually
        ' release any objects instantiated. Make sure you set the ref to nothing and
        ' also call the dispose method if it has one.

        ' under some conditions, we don't want to destroy the ReportDocument (e.g. report page-to-page navigation)
        If blnForce OrElse Me.blnPageHasFatalError OrElse (Not Me.CrystalUseCache) Then ' do not release when using cache! (unless forced)
            If Not crReportDocument Is Nothing Then Me.crReportDocument.Close()
            If Not crReportDocument Is Nothing Then Me.crReportDocument.Dispose()
            If Not thisWebAppUser Is Nothing Then Me.thisWebAppUser.Dispose()
            Me.thisWebAppUser.ClearReportCache() ' we are using HttpContext.Current.Cache.Item instead of sessions to save CR document
        End If

        ' the rest of the items, we'll always want to clean up
        If Not crParameterFieldDefinitions Is Nothing Then crParameterFieldDefinitions.Dispose()
        If Not crParameterFieldDefinition Is Nothing Then crParameterFieldDefinition.Dispose()

        crParameterFields = Nothing
        crParameterField = Nothing
        crParameterFieldName = Nothing
        crParameterValues = Nothing
        crParameterDiscreteValue = Nothing
        crParameterDefaultValue = Nothing
        crParameterRangeValue = Nothing

        '
        If Not crSections Is Nothing Then crSections.Dispose()
        If Not crSection Is Nothing Then crSection.Dispose()
        If Not crReportObjects Is Nothing Then crReportObjects.Dispose()
        If Not crReportObject Is Nothing Then crReportObject.Dispose()
        If Not crSubreportObject Is Nothing Then crSubreportObject.Dispose()
        If Not crDatabase Is Nothing Then crDatabase.Dispose()
        If Not crTables Is Nothing Then crTables.Dispose()
        If Not crTable Is Nothing Then crTable.Dispose()
        crLogOnInfo = Nothing
        crConnInfo = Nothing

        crDiskFileDestinationOptions = Nothing
        ConnParam = Nothing

        If Not subRepDoc Is Nothing Then subRepDoc.Dispose()
    Catch ex As Exception
        Me.thisWebAppUser.SendSysAdminMessage("Failed CR cleanup", ex.ToString)
    End Try


    ' yes, use of the GC.Collect (and even more the GC.WaitForPendingFinalizers) is highly controversial
    ' 
    ' the reality is that rendering crystal reports is rather slow compared to most web operations
    ' so it is expected that waiting for GC will have relatively little performance impact
    ' and will in fact, help tremendously with memory management.
    '
    ' try setting these values to 1 and confirm for yourself by instantiating multiple crDocuments in different browsers if you don't believe it:
    '
    '   HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\InprocServer 
    '   HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\Server 
    '
    ' or google this error: The maximum report processing jobs limit configured by your system administrator has been reached
    ' 
    ' I believe the problem is that on very fast servers, the page unloads and stops processing code to properly cleanup the Crystal Report objects
    ' 
    ' This is done in 3 places: 
    '   Report Viewer (Page_Unload and CrystalReportViewer1_Unload) rendering a report will of course always using a processing job
    '   Report Parameter Selector (Page_Unload) loading a crDocument without rendering a report still counts towards CR processing job limit.
    '   Custom Control crReportParameterSelectionTable (Public Overrides Sub dispose())

    GC.Collect()
    GC.WaitForPendingFinalizers()

End Sub
'***********************************************************************************************************************************
' 
'***********************************************************************************************************************************
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
    'If Me.IsCallback Then Exit Sub ' the menutree causes callbacks, but we are not interested

    crCleanup()
    ' response object not available here, so cannot redirect (such as in the case of XLS opeing in a separate window)

    ' if for some crazy reason there is STILL a crReportDocument, set it to nothing
    '        If Not crReportDocument Is Nothing Then Me.crReportDocument = Nothing
    '        Me.CrystalReportViewer1 = Nothing
End Sub

Private Sub CrystalReportViewer1_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Unload
    'If Me.IsCallback Then Exit Sub ' the menutree causes callbacks, but we are not interested

    crCleanup()
End Sub

End Region

Bratislava answered 23/8, 2016 at 17:33 Comment(1)
reminder that stuffing data into a crRoportDocument should occur in Page_Init, and not Page_Load. See https://scn.sap.com/thread/1070812Bratislava

© 2022 - 2024 — McMap. All rights reserved.