mscorlib.dll

时间:2017-03-29 05:15:18

标签: c# crystal-reports

我的项目工作正常,但在尝试打印甚至显示报告时,我有一段时间出现这种奇怪的错误。有时它工作正常,但当我尝试多次打印此报告超过50或其他什么时,它会抛出此错误。我花了几周时间试图找出解决方案。我已经多次检查过没有递归循环,现在我只是拔毛了。任何帮助都将受到高度赞赏。

在Form_Load中初始化:

ReportDocument cryRptEdu = new ReportDocument();
TableLogOnInfos crtableLogoninfosEdu = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfoEdu = new TableLogOnInfo();
ConnectionInfo crConnectionInfoEdu = new ConnectionInfo();

try
{
    cryRptEdu.Load(rptpathEdu);
}
catch (Exception x)
{
    KryptonMessageBox.Show(x.Message, "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}

crConnectionInfoEdu.ServerName = Program.serverName;
crConnectionInfoEdu.DatabaseName = Program.dbName;
crConnectionInfoEdu.UserID = Program.saName;
crConnectionInfoEdu.Password = Program.pw;
Tables CrTables = cryRptEdu.Database.Tables;
foreach (Table CrTable in CrTables)
{
    crtableLogoninfoEdu = CrTable.LogOnInfo;
    crtableLogoninfoEdu.ConnectionInfo = crConnectionInfoEdu;
    CrTable.ApplyLogOnInfo(crtableLogoninfoEdu);
}

打印按钮:

cryRptEdu.SetParameterValue("percentage", percentage);
cryRptEdu.SetParameterValue("grades", grade);
cryRptEdu.SetParameterValue("position", position);
cryRptEdu.SetParameterValue("attendance", attendance);
cryRptEdu.SetParameterValue("midTermPercentage", midTermPercentage);
cryRptEdu.SetParameterValue("finalPercentage", finalPercentage);
cryRptEdu.SetParameterValue("aggregatePercentage", aggregatePercentage);
cryRptEdu.SetParameterValue("midTermGrade", midTermGrade);
cryRptEdu.SetParameterValue("finalGrade", finalGrade);
cryRptEdu.SetParameterValue("aggrgateGrade", aggregateGrade);
cryRptEdu.SetParameterValue("tl1", tl1);
cryRptEdu.SetParameterValue("tl2", tl2);
cryRptEdu.SetParameterValue("pl1", pl1);
cryRptEdu.SetParameterValue("pl2", pl2);
if (print)
    cryRptEdu.PrintToPrinter(1, true, 1, 1);
else
    cryRptEdu.ExportToDisk(ExportFormatType.PortableDocFormat, exportPath + ID + ".pdf");

打印时:

enter image description here

enter image description here

堆栈追踪:

enter image description here

1 个答案:

答案 0 :(得分:0)

最后我使用backgroundworker解决了这个问题。