Windows应用程序中的ReportViewer无法在XP中运行

时间:2017-08-18 12:12:10

标签: c# windows winforms rdlc

在使用VS13(Windows 8.1)开发的Windows应用程序中,我能够看到rdlc报告(使用报告查看器)。但是当我尝试在xp机器中查看报告时,应用程序正在关闭。 我也在我的rdlc报告中使用子报告。我不知道确切的问题,但我觉得this.reportViewer1.RefreshReport();是我得到问题的地方。当我评论this.reportViewer1.RefreshReport();并检查XP机器时,我看不到任何数据,但应用程序没有关闭,我能够看到报告。我已经使用版本11的Microsoft.ReportViewer.Common.dll和Microsoft.ReportViewer.WinForms.dll开发了所有报告。为了使应用程序在XP机器上运行,我编译了应用程序并引用了v10 dll。我不知道这里是否有任何问题。任何人都可以帮忙解决这个问题吗?

这是Report Viewer Form背后的代码:

public KCForm21(XMLParameters objParams)
{
    gObjLog = AppLogWriter.Instance;
    gObjParams = objParams;
    InitializeComponent();
    this.Size = Screen.PrimaryScreen.WorkingArea.Size;
    DataTable dt = new DataTable();

    try
    {
        dtsurvey = new DataTable();
        DAClass obj = new DAClass();
        dt = obj.Win_Get_KC_Header(gObjParams);
        reportViewer1.ProcessingMode = ProcessingMode.Local;
        gObjLog.WriteToLog("KathaChangeForm21 - Before binding RDLC.");
        reportViewer1.LocalReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + ConfigurationManager.AppSettings["ReportPath"].ToString().Trim() + "KathaChangeForm21.rdlc";
        gObjLog.WriteToLog("KathaChangeForm21 - After binding RDLC.");
        gObjLog.WriteToLog("RDLC Path : " + reportViewer1.LocalReport.ReportPath.ToString().Trim());
        reportViewer1.LocalReport.DataSources.Clear();
        ReportDataSource datasource = new ReportDataSource("DataSet1", dt);
        reportViewer1.LocalReport.DataSources.Clear();
        reportViewer1.LocalReport.DataSources.Add(datasource);
        dtsurvey = dt;
        this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(KCForm21SubReport);
        //this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
        //this.reportViewer1.ZoomMode = ZoomMode.Percent;
        //this.reportViewer1.ZoomPercent = 50;
        this.reportViewer1.RefreshReport();
        //reportViewer1.Refresh();
    }
    catch (Exception ex)
    {
        gObjLog.WriteToLog("KCForm21 : " + ex.Message);
    }
    finally
    {
        gObjLog = null;
    }
    //this.reportViewer1.RefreshReport();
}

public void KCForm21SubReport(object sender, SubreportProcessingEventArgs e)
{
    DAClass obj = new DAClass();
    gObjLog = AppLogWriter.Instance;

    try
    {
        if (count % 2 == 0)
        {

            DataTable dt = new DataTable();
            dt = obj.Win_Get_KC_OldOwn(gObjParams, dtsurvey.Rows[oldowncount]["land_code"].ToString());
            ReportDataSource subRptSource = new ReportDataSource("OldOwner", dt);
            e.DataSources.Add(subRptSource);
            oldowncount++;

        }

        else
        {
            DataTable dtNew = new DataTable();
            dtNew = obj.Win_Get_KC_NewOwn(gObjParams, dtsurvey.Rows[newowncount]["land_code"].ToString());
            ReportDataSource subRptSourceNew = new ReportDataSource("NewOwner", dtNew);
            e.DataSources.Add(subRptSourceNew);
            newowncount++;
        }
        count++;
    }
    catch (Exception ex)
    {
        gObjLog.WriteToLog("KCForm21SubReport : " + ex.Message);
    }
}

0 个答案:

没有答案