I created a report library .dll to print reports ad-hoc with no previewing, so I can use it in a rest api. This has been working fine since installation over 4months ago.
I have just updated to v 13.2.19.1030, now when a report is trying to print is get the following error..
"The data area passed to a system call is too small"
I have copied and pasted my code below..
-------------------------------------------------------------------------------
public void printPalletLabel(string palletBarcode, string courier, string printerName, short copies)
{
string reportName = _basePath + "\\Reports\\";
try
{
// CREATE A REPORT INSTANCE FROM THE REPORT FILE
switch (courier.ToUpper())
{
case "DPD":
reportName += "palletLabel_DPD.trdp";
break;
case "YODEL":
reportName += "palletLabel_Yodel.trdp";
break;
default:
reportName += "palletLabel_UKMail.trdp";
break;
}
// REMOVE URI START IS EXISTS
if (reportName.StartsWith("file:\\"))
reportName = reportName.Substring(6);
var reportInstance = UnpackageReport(reportName);
if (reportInstance != null)
{
// MODIFY CONNECTIONSTRING AND PASS PARAMETER
var ds = reportInstance.DataSource;
var sqlDataSource = (SqlDataSource)ds;
sqlDataSource.ConnectionString = _connectionString;
sqlDataSource.ProviderName = "System.Data.SqlClient";
sqlDataSource.Parameters["@palletBarcode"].Value = palletBarcode;
printReport(reportInstance, printerName, copies);
}
}
catch (Exception ex)
{
error = "reporting.printPalletLabel(): " + ex.Message;
}
}
private void printReport(Telerik.Reporting.Report report, string printerName, short copies)
{
try
{
InstanceReportSource reportSource = new InstanceReportSource
{
ReportDocument = report
};
// SET PRINTER
var printerSettings = new System.Drawing.Printing.PrinterSettings
{
PrinterName = printerName,
Copies = copies
};
// PRINT REPORT
var reportProcessor = new ReportProcessor();
reportProcessor.PrintReport(reportSource, printerSettings);
}
catch (Exception ex)
{
error = "reporting.printReport(): " + ex.Message;
}
}
private Telerik.Reporting.Report UnpackageReport(string reportName)
{
var reportPackager = new ReportPackager();
try
{
using (var sourceStream = System.IO.File.OpenRead(reportName))
{
var report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
return report;
}
}
catch (Exception ex)
{
error = "reporting.UnpackageReport(): " + ex.Message;
return null;
}
}
------------------------------------------------------------------------------------
The error occurs at the following line within printReport()
reportProcessor.PrintReport(reportSource, printerSettings);
Any ideas?
Thanks
Andy