One or more parameters required to run the report are not specified

I am trying to print an RDLC file directly without showing the Microsoft Report Viewer, I executed

Can someone tell me which parameter is required for me to skip? or how can I find more details 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 _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; } 
+6
printing reportviewer rdlc
source share
5 answers

I just found that I passed the parameter value as an empty string, for example parameter = "" this will give you this error

took some time

+15
source share

Allow null in the parameter properties will resolve this problem.

+5
source share

Cause. A local report does not allow you to pass empty or null parameters, which I do not know, but this throws an exception.

Bugfix: one way to find out which parameter causes an Exception call var result = report.LocalReport.GetParameters(); method, in the array of results that it has result[0].State property, if it is MissingValidValue it throws an exception.

Example:

  var rv = new ReportViewer { ProcessingMode = ProcessingMode.Local }; rv.LocalReport.ReportPath = Server.MapPath("~/PrintForms/FromForm.rdlc"); rv.LocalReport.Refresh(); string mimeType; string encoding; string filenameExtension; string[] streamids; Warning[] warnings; rv.LocalReport.SetParameters(new ReportParameter("ClientName", "გიორგი გიორგაძე")); rv.LocalReport.SetParameters(new ReportParameter("Account", "888"));var streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); return File(streamBytes, mimeType); 

The code above works fine, but if you change the line for adding parameters to:

 rv.LocalReport.SetParameters(new ReportParameter("Account", null)); 

The value of the ReportParameter State report will be MissingValidValue, and this will throw an exception.

+3
source share

If you really need to pass an empty string as a value, you can do the following:

  • open the properties of the parameters (right-click your parameter in the report data panel);
  • check the Allow empty value ("") box.

It helped me decide.

+1
source share

In another way, it may happen that you use shared datasets and you include DataSets that your report does not use. Each report must define its own version of parameters for each common data set locally. Therefore, if you included a data set as one of your data sources, and you did not explicitly determine how this particular report will pass parameters to this data set, you will receive this error.

0
source share

All Articles