VB.Net Crystal报表需要时间加载 [英] VB.Net crystal report takes time to load

查看:352
本文介绍了VB.Net Crystal报表需要时间加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am developing program with vb.net 2010 with windows 7. I have crystal reports in my project. Now when I display the report for the first time it takes quite long time than opening the report again, and that is because crystal report run time engine is loaded from the first time. How can I run the crystal report run time engine immediately after running the program or even after running the computer itself to load crystal report fast?

推荐答案

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

I've worked with CR many times now. The only way I've found is to call a dummy report (as someone posted on sap's forum). Make a function that try to call "dummy.rpt" i.e. and catch the exception. You'll need to do this in a second thread so the UI doesn't freeze.

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:

And in my 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或线程。

Then you could use a BackgroundWorker or a Thread.

这篇关于VB.Net Crystal报表需要时间加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆