【问题标题】:Crystal Reports Exception: The maximum report processing jobs limit configured by your system administrator has been reachedCrystal Reports 异常:已达到系统管理员配置的最大报表处理作业限制
【发布时间】:2012-03-23 16:59:29
【问题描述】:

我遇到了一个非常错误的问题,在 ASP.NET 应用程序中,在同时多次查看同一份报告后,我得到了这个异常:

您的系统配置的最大报告处理作业限制 已联系管理员。

等等,我知道那里有大量的解决方案,但它们都不适用于我。

  1. 我把 ReportDocument.Close(); ReportDocument.Dispose();在 CrystalReportViewer_Unload 事件中,仍然抛出异常。

    Private Sub CrystalReportViewer1_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Unload reportFile.Close() reportFile.Dispose() GC.Collect() End Sub

  2. 我将 HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\InprocServerHKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\Server 中的 PrintJobLimit 注册表编辑为 -1 甚至 9999,但仍然抛出异常。

这是我调用报告的代码 sn-p:

 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

【问题讨论】:

    标签: crystal-reports crystal-reports-2010


    【解决方案1】:

    毕竟,您必须处置您的报表实例。 如果您在显示报告后将其处置,您将永远不会再次看到错误“已达到系统管理员配置的最大报告处理作业限制”。

      Dim report1 As rptBill = clsBill.GetReport(billNumber)
    
      rpt.Print()
    
      'Cleanup the report after that!
      rpt.Close()
      rpt.Dispose()
    

    【讨论】:

      【解决方案2】:

      我建议将您的 close/dispose/gc.collect 代码移到该卸载过程之外。换句话说:

      1. 加载报告
      2. 分配给查看器控件
      3. 在查看器控件中显示报告
      4. 关闭查看器控件并卸载(完全)
      5. 然后在任何查看器控制代码之外关闭/dispose/gc.collect

      我的猜测是在清理报表时查看器控件没有完全关闭。

      Crystal 是一个非常占用内存且非常挑剔的过程。

      【讨论】:

      • 我也在尝试通过使用...但是显示对象引用类型异常,所以我必须使用看起来不太好的卸载方法。
      • 你能把这5个点的完整代码贴在这里吗。
      【解决方案3】:

      Crystal Report 文档实现IDisposable 接口。因此,您所要做的就是用using 语句将报表的实例括起来。一旦using 语句完成,它将自动关闭和处置。你可以这样写:

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

      或(取决于您的上下文):

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

      【讨论】:

        【解决方案4】:

        您好,我来不及回答, 所有回复都有效,我已经看到了,但如果您仍然面临同样的问题和错误,请进入“windows”目录下的 TEMP 文件夹并删除所有水晶报表实例。 我这么说是因为上述所有选项都可以使用,但您仍然处于最大范围,因此首先删除所有实例,然后应用上述所有建议。 谢谢

        【讨论】:

          【解决方案5】:

          确保 IIS 用户有足够的权限删除“c:/windows/temp”文件夹中的文件。

          一旦我向该文件夹提供写入权限,我就会遇到同样的问题,然后它就解决了我的问题。另外,请确保在生成文件后处理该对象

          【讨论】:

          • 如果 IIS 用户有权限在 temp 中创建文件,为什么之后没有权限删除它们?
          【解决方案6】:

          我在本地报表服务器上工作。我在其他电脑上托管了我的网络应用程序。当我遇到这样的错误时,我只是做了 IISRESET 并且现在工作正常。

          试试这个,这对你有帮助。

          【讨论】:

            【解决方案7】:

            确保您使用 PUSH 模型来显示您的报告。接下来,您必须在服务器的注册表中进行一项更改:按照路径:

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

            您会看到一个项目“PrintJobLimit”,您会看到它的默认值为 75。这意味着服务器一次只能处理 75 个报告。 不用担心,只需将值修改为 -1

            【讨论】:

            • 请@Mansoor 检查我写的问题,我已经这样做了。
            • 您实际上是在使打印作业不受限制。这是非常非常糟糕的做法。还不如告诉他们每次发生时都重新启动 IIS,你会没事的。
            【解决方案8】:

            毕竟你必须Dispose你的报告实例。如果您在显示报告后Dispose,您将永远不会看到错误:

            已达到系统管理员配置的最大报表处理作业限制

            代码:

            Dim report1 As rptBill = clsBill.GetReport(billNumber)
            
            rpt.Print()
            
            'Cleanup the report after that!
            rpt.Close()
            rpt.Dispose()
            

            【讨论】:

              【解决方案9】:

              就我而言,报告有 4 个子报告...

              为我解决的问题是在以下 Regedit 路径中将“PrintJobLimit”的值从 75 更改为 500:

              • \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

              【讨论】:

              • 此解决方案适用于我的仅限客户端的 Crystal Report 查看器 WinForm 应用程序。我只需要更改“服务器”版本。我刚把它改成500,瞧。我的应用程序不会随着时间的推移泄漏内存或变慢。具有这种愚蠢限制的是查看器控件。
              【解决方案10】:

              我知道此线程较旧,但如果您将应用程序池设置“回收...”配置为在 180 分钟而不是 1740 分钟(默认)进行回收,这可能会释放所需的资源。

              【讨论】:

                【解决方案11】:

                除了 GC.Collect、关闭和处置之外,我最终还使用了 GC.WaitForPendingFinalizers。我相信我的网页可能在正确处理垃圾之前提前卸载并停止线程处理(真的吗?)

                这是在服务器 2012、SQL 2012、CR 13.0.2000.0 上

                这是我的代码:

                #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
                

                结束区域

                【讨论】:

                【解决方案12】:

                卸载页面时使用这些方法

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

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

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2011-08-03
                  • 1970-01-01
                  • 2011-02-27
                  • 1970-01-01
                  • 1970-01-01
                  相关资源
                  最近更新 更多