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

时间:2012-03-06 08:04:33

标签: crystal-reports crystal-reports-2010

我遇到了一个非常错误的问题,在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,仍然抛出异常。

  3. 以下是我调用报告的代码段:

     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
    

11 个答案:

答案 0 :(得分:12)

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

  Dim report1 As rptBill = clsBill.GetReport(billNumber)

  rpt.Print()

  'Cleanup the report after that!
  rpt.Close()
  rpt.Dispose()

答案 1 :(得分:8)

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

  1. 加载报告
  2. 分配给Viewer Control
  3. 在Viewer Control中显示报告
  4. 关闭查看器控制和卸载(完全)
  5. 然后在任何查看器控制代码之外关闭/ dispose / gc.collect
  6. 我的猜测是在清理报告时,查看器控件未完全关闭。

    Crystal是一个内存密集型的过程,非常挑剔。

答案 2 :(得分:2)

问候我来不及回答, 所有的回复都在工作,我已经看过,但万一你仍然遇到同样的问题和错误,那么请一次进入" windows"下的TEMP文件夹。目录并删除水晶报告的所有实例。 我之所以这样说是因为以上选项都可以使用,但您仍处于最大范围内,因此首先删除所有实例然后应用以上所有建议。 感谢

答案 3 :(得分:2)

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

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

或(取决于您的具体情况):

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

答案 4 :(得分:1)

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

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

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

答案 5 :(得分:1)

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

试试这个,这可以帮到你。

答案 6 :(得分:1)

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

  

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

代码:

Dim report1 As rptBill = clsBill.GetReport(billNumber)

rpt.Print()

'Cleanup the report after that!
rpt.Close()
rpt.Dispose()

答案 7 :(得分:1)

就我而言,该报告有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

答案 8 :(得分:0)

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

这是在Server 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

结束地区

答案 9 :(得分:0)

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

一旦我向该文件夹提供写入权限,我就面临同样的问题,然后它解决了我的问题。还要确保在生成文件后处置该对象

答案 10 :(得分:0)

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