I'm trying to print a RDLC file directly without showing Microsoft Report Viewer, I have followed the MSDN's example but now, every time I call the "Render" method of my instance of LocalReport class it throws the "One or more parameters required to run the report have not been specified." exception.
Can anyone tell me which parameter is required that I missed? or how can I find more detail about this exception?
LocalReport report = new LocalReport();
report.ReportPath = System.Windows.Forms.Application.StartupPath + "\\" + rdlcFileName;
report.EnableExternalImages = true;
ReportParameter[] reportParams = new ReportParameter[]
{
new ReportParameter("LogoAddress", settings.LogoFileName),
new ReportParameter("FooterValue", settings.InvoicesFooter)
};
report.SetParameters(reportParams);
report.DataSources.Add(new ReportDataSource("Invoice", new PrintableInvoice[] { invoice }));
report.DataSources.Add(new ReportDataSource("InvoiceItem", invoiceItems));
Warning[] warnings;
try
{
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.25in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>0.25in</MarginBottom>" +
"</DeviceInfo>";
m_streams = new List<Stream>();
report.Render("Image", deviceInfo, _CreateStream, out warnings);
foreach( Stream stream in m_streams )
stream.Position = 0;
}
catch( Exception ex )
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
and the _CreateStream is:
private Stream _CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new FileStream(name + "." + fileNameExtension, FileMode.Create);
m_streams.Add(stream);
return stream;
}