Reputation: 85
Hi All i am getting following error in crystal reports production. i have tried repordocument diposal. and increasing registry values both case is not working. attached error below
[EDIT]
please check below my code this my exact code scenario
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If rpt IsNot Nothing Then
For Each t As Table In rpt.Database.Tables
t.Dispose()
Next
rpt.Close()
rpt.Dispose()
rpt = Nothing
' GC.Collect()
End If
Catch ex As Exception
End Try
'Session("RPTManagmentName") = Session("RPTManagmentName") & " - " & Session("RPTBranchName")
rpt = New ReportDocument
Select Case Request.QueryString("RPT")
Case 6
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
Report.Load(Server.MapPath("Reports/RPTBalances.rpt"))
Report.SetDataSource(Session("BalancesReportDataSet").Tables(0))
Report.SetParameterValue("ManagmentName", Session("RPTManagmentName"))
Report.SetParameterValue("BranchName", Session("RPTBranchName"))
Report.SetParameterValue("AccountName", Session("RPTAccountName"))
Report.SetParameterValue(" FromDate", CStr(Session("RPTFromDate")))
Report.SetParameterValue("ToDate", CStr(Session("RPTToDate")))
Session("report") = Report
End Select
CRVShow.ReportSource = rpt
CRVShow.DataBind()
End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
Try
If rpt IsNot Nothing Then
For Each t As Table In rpt.Database.Tables
t.Dispose()
Next
rpt.Close()
rpt.Dispose()
rpt = Nothing
' GC.Collect()
End If
If CRVShow IsNot Nothing Then
CRVShow.ReportSource = Nothing
CRVShow.Dispose()
CRVShow = Nothing
End If
Catch ex As Exception
End Try
Try
rpt.Close()
rpt.Dispose()
Catch ex As Exception
End Try
End Sub
Upvotes: 0
Views: 229
Reputation:
I would recommend moving your close/dispose/gc.collect code outside of that unload process. In other words:
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.
Upvotes: 1