找回密码
 立即注册

QQ登录

只需一步,快速开始

linyimin

注册会员

12

主题

25

帖子

97

积分

注册会员

积分
97

[已处理] 加载报表暴机

linyimin
注册会员   /  发表于:2023-12-27 11:09  /   查看:993  /  回复:1
1金币
public void ReLoadReport(String strTemplateName)
        {

            m_strReportName = strTemplateName;
            // m_strCurReport = System.Windows.Forms.Application.StartupPath + "\\Report\\ReportTemplate\\" + strTemplateName;
            m_strCurReport = m_strTemplatePath + strTemplateName;
            if (!System.IO.File.Exists(m_strCurReport))
            {
                //MessageBox.Show(m_strCurReport + "文件不存在");
                m_strCurReport = m_strTemplatePath + "EmptyView.rdlx";
            }
            //是否单页显示
           // this.m_pageReportViewer.GalleyMode = true;
            this.m_pageReportViewer.ReportViewer.GalleyMode = true;



            this.Dispatcher.Invoke(
                new Action(
                    delegate
                    {
                        FileInfo info = new System.IO.FileInfo(m_strCurReport);
                        this.m_curPage = new GrapeCity.ActiveReports.PageReport(info);
                        this.m_curPage.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(locateData);
                        this.m_pageReportViewer.LoadDocument(m_curPage.Document);
                    }
                )
            );
        }

private void locateData(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
  {
            args.Data = new DataTable();
}



12版本.net报表,使用上面方法加载报表,第一次正常显示,第二次暴机


附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

问题描述: 报错NullReferenceException 问题回答: 目前从报错来看,只能知道是第二次运行的时候, this.m_pageReportViewer.LoadDocument(m_curPage.Document); 这个里面有一个对象是null。 这个目前只能打断点您可以先试一下。主要是看第二次运行的时候, m_pageReportViewer是null还是m_curPage.Document是null。主要还是排查。 页面viewer对象没有加载出来还是pagereport对象没有加载好。别的目前也确实不好排查 ...

1 个回复

倒序浏览
最佳答案
最佳答案
Felix.LiWyn认证
超级版主   /  发表于:2023-12-27 11:09:56
来自 2#
问题描述:

报错NullReferenceException

问题回答:
目前从报错来看,只能知道是第二次运行的时候,
this.m_pageReportViewer.LoadDocument(m_curPage.Document);
这个里面有一个对象是null。

这个目前只能打断点您可以先试一下。主要是看第二次运行的时候,
m_pageReportViewer是null还是m_curPage.Document是null。主要还是排查。
页面viewer对象没有加载出来还是pagereport对象没有加载好。别的目前也确实不好排查。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部