我们有一个WPF应用程序,除其他外,使用异步sintax大约每两分钟打印一次报告。该报告使用 SAP Crystal Reports,Microsoft Visual Studio 13.0.15.1840的版本进行。已开发应用程序的计算机还具有 SAP Crystal Reports运行时引擎64位13.0.15.1840 。以下是异步代码的代码:
private async void StartAsyncOperation()
{
while (true)
{
try
{
if (_isActive)
{
await Task.Run(() =>
{
PrintTravelSheet();
});
await Task.Delay(_delayPrinterTime);
}
else break;
}
catch (Exception e)
{
SendWarningAlerts(string.Format("Error!!! You should be worried! \n {0}", e));
}
}
}
使用 SAP Crystal Reports运行时64位13.0.8.1216 将应用程序部署到具有Windows Server 2012的计算机上。以下是 PrintTravelSheet 用于打印的代码:
try
{//_hojaViajera is my Crystal Report
_hojaViajera = new HojaViajera();
InitializeTravelSheet(printerConfig, tracking, configBits);
System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
printerSettings.PrinterName = printerConfig.PrinterName;
_hojaViajera.PrintToPrinter(printerSettings, new System.Drawing.Printing.PageSettings(), false);
}
catch (Exception ex)
{
//here I send emails with error log
}
finally
{
_hojaViajera.Close();
_hojaViajera.Dispose();
}
通常应用程序可以正常运行两周或更多,但在此之后处理打印操作的线程崩溃并且我收到以下异常:
** **Message Error: CrystalDecisions.CrystalReports.Engine.InternalException: There are not enough free System Resources to perform this operation.
Error formatting Field Object.
Error in File temp_1d4e04c2-7dc4-4896-a347-edc086582c07 {BFFFC1AF-E765-4FF0-BBEC-02929B533486}.rpt:
Low system resources.. ---> System.Runtime.InteropServices.COMException: There are not enough free System Resources to perform this operation.
Error formatting Field Object.
Error in File temp_1d4e04c2-7dc4-4896-a347-edc086582c07 {BFFFC1AF-E765-4FF0-BBEC-02929B533486}.rpt:
Low system resources..
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetPage(PageRequestContext pPageRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.GetPage(PageRequestContext pageReqContext)
--- End of inner exception stack trace ---
at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at CrystalDecisions.ReportSource.EromReportSourceBase.HandleException(Exception exception)
at CrystalDecisions.ReportSource.EromReportSourceBase.GetPage(PageRequestContext pageReqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.QueryPageSettingsEventHandler(Object sender, QueryPageSettingsEventArgs e)
at System.Drawing.Printing.PrintDocument.OnQueryPageSettings(QueryPageSettingsEventArgs e)
at System.Drawing.Printing.PrintDocument._OnQueryPageSettings(QueryPageSettingsEventArgs e)
at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(PrinterSettings printerSettings, PageSettings pageSettings, PrintLayoutSettings layoutSettings, Boolean reformatReportPageSettings)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(PrinterSettings printerSettings, PageSettings pageSettings, PrintLayoutSettings layoutSettings, Boolean reformatReportPageSettings)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(PrinterSettings printerSettings, PageSettings pageSettings, Boolean reformatReportPageSettings)**
**
然后我关闭应用程序并重新开始,一切恢复正常。到目前为止,我无法在我的机器甚至服务器上重现错误。欢迎任何帮助或解决方法。