我試圖直接打印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