大家好我在水晶报道制作中遇到以下错误。我尝试过repordocument diposal。并且增加注册表值这两种情况都不起作用。附上的错误如下
[编辑]
请在我的代码下面查看我的确切代码方案
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
答案 0 :(得分:2)
我建议将close / dispose / gc.collect代码移到该卸载过程之外。换句话说:
我的猜测是在清理报告时,查看器控件未完全关闭。
Crystal是一个内存密集型的过程,非常挑剔。