Crystal reports &引用;“对象引用异常”;尝试导航到网页中Crystal报表的下一页时

Crystal reports &引用;“对象引用异常”;尝试导航到网页中Crystal报表的下一页时,crystal-reports,Crystal Reports,我有一个Crystal report,它根据时段或特定的客户端ID显示客户端数据。该报告由2个子报告组成,如果从Crystal report(CR)运行,则根据正确CR对话框中接受的参数完美工作 从网页运行时,第一个报表页面在ReportViewer对象中正确显示。通过使用SQL Profiler进行检查,使用正确的参数正确执行查询,为第一个子报表重新排列1条记录,为第二个子报表重新排列2条记录。 但是,单击报告切换到下一页时,会出现一条消息:“对象引用未设置为对象的实例。” 下面是Report

我有一个Crystal report,它根据时段或特定的客户端ID显示客户端数据。该报告由2个子报告组成,如果从Crystal report(CR)运行,则根据正确CR对话框中接受的参数完美工作

从网页运行时,第一个报表页面在ReportViewer对象中正确显示。通过使用SQL Profiler进行检查,使用正确的参数正确执行查询,为第一个子报表重新排列1条记录,为第二个子报表重新排列2条记录。 但是,单击报告切换到下一页时,会出现一条消息:“对象引用未设置为对象的实例。”

下面是ReportViewer的代码:

_crystalReportViewer.DisplayGroupTree = false;
_crystalReportViewer.HasCrystalLogo = false;
_crystalReportViewer.HasDrillUpButton = false;
_crystalReportViewer.HasToggleGroupTreeButton = false;
_crystalReportViewer.HasViewList = false;
_crystalReportViewer.ReportSource = _myReportDocument;

[...]

protected void Page_UnLoad (object sender, EventArgs e)
    {
        if (_crystalReportViewer != null)
            _crystalReportViewer.Dispose();
        _crystalReportViewer = null;
  }
调试代码似乎一切正常。我想问题可能在于ReportViewer或CR本身,但我找不到解决方法。你能给我一些建议吗?
提前谢谢

我发现问题出在Page_UnLoad事件上:每次单击Cristal Report中的“下一页/上一页”按钮时都会调用该事件,从而处理查看器并导致对象引用异常

我添加了一个条件来检查是否发生回发:

    protected void Page_UnLoad (object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (_crystalReportViewer != null)
                _crystalReportViewer.Dispose();
            _crystalReportViewer = null;

            if (_myReportDocument != null)
            {
                _myReportDocument.Close();
                _myReportDocument.Dispose();
            }
            _myReportDocument = null;

            GC.Collect();
        }           
    }
不幸的是,一个小问题仍然存在:在测试机器上,一切正常,但一旦部署到DEV机器上(它们是两个具有相同设置的不同服务器),就可以只查看报告的前两条记录,然后单击CR查看器的“下一步”按钮,什么都不会发生。CR的所有其他功能,如“转到”和“打印”,都可以正常工作。 这很奇怪,因为数据库设置是正确的,报告和代码是一样的…你知道吗