我试图直接打印RDLC文件而没有显示Microsoft Report Viewer,我按照MSDN's example但现在每次调用“Render”方法我的LocalReport类实例抛出“运行报告所需的一个或多个参数没有被指定”。例外。运行报告所需的一个或多个参数没有指定
任何人都可以告诉我哪些参数是我错过的吗?或者我如何找到关于这个异常的更多细节?
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);
}
和_CreateStream是:
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;
}
回复发现:http://social.msdn.microsoft.com/Forums/zh/vsreportcontrols/thread/7cce3c91-f876-417a-81cc-10e10dde0e40 – MilkyWayJoe 2012-02-15 20:07:07