VB.Net水晶报告需要时间来加载

时间:2013-11-17 10:04:04

标签: vb.net performance crystal-reports load

我正在使用Windows 7开发vb.net 2010程序。我的项目中有水晶报告。现在,当我第一次显示报告时,再次打开报告需要很长时间,这是因为第一次加载水晶报告运行时引擎。如何在运行程序后立即运行晶体报告运行时引擎,或者甚至在运行计算机本身后快速加载晶体报告?

1 个答案:

答案 0 :(得分:0)

我现在多次与CR合作过。我发现的唯一方法是打电话给虚拟报告(就像有人在sap论坛上发布的那样)。创建一个尝试调用“dummy.rpt”的函数,即捕获异常。您需要在第二个线程中执行此操作,以便UI不会冻结。

Public Sub LoadDummyReport()
    'SAP suggests is better to load a dummy report at the first app excution using a thread or a background worker to get DLLs ready when calling your production reports.
    Try
        ReportClass.Generate("", "", "dummy", Nothing, "", "", "", "", "")
    Catch ex As Exception
        ' This will fail because ReportClass will throw an ex. Dummy.rpt does not exist but will load the crystal dlls.
    End Try 
End Sub

在我的ReportClass中:

Try
    rpt.Load(....)
Catch ex As Exception
    If reportName <> "dummy" Then
         Throw New Exception("ReportFileNotFound") 
    Else
         Throw New Exception("DummyRPTLoaded") 'In case you need to catch the ex.
    End If
End Try

然后你可以使用BackgroundWorker或Thread。