13

我面临一个非常错误的问题,在 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. 我将 PrintJobLimit 注册表编辑为 -1HKEY_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\Server9999,但仍然抛出异常。

这是我调用报告的代码片段:

 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
4

12 回答 12

21

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

  Dim report1 As rptBill = clsBill.GetReport(billNumber)

  rpt.Print()

  'Cleanup the report after that!
  rpt.Close()
  rpt.Dispose()
于 2012-03-06T16:12:51.720 回答
11

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

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

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

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

于 2012-03-06T15:58:35.977 回答
5

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

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

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

using(var report = new ReportDocument())
{
     // your logic here
}
于 2016-06-17T18:50:03.077 回答
3

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

于 2015-12-15T11:18:26.983 回答
2

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

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

于 2018-01-18T04:45:34.780 回答
1

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

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

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

于 2015-03-24T12:06:11.303 回答
1

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

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

于 2016-03-02T11:45:00.487 回答
1

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

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

代码:

Dim report1 As rptBill = clsBill.GetReport(billNumber)

rpt.Print()

'Cleanup the report after that!
rpt.Close()
rpt.Dispose()
于 2017-04-10T11:16:59.150 回答
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

于 2018-06-02T18:24:29.913 回答
1

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

于 2019-01-14T17:10:40.987 回答
0

除了 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

结束区域

于 2016-08-23T17:33:15.447 回答
0

卸载页面时使用这些方法

    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();
        }
    }
于 2021-11-29T07:21:31.413 回答