0

I am having a heck of a time figuring this out. I am passing parameters the right way (followed some tutorials on web). And the .rdlc has corrent notation (expression) for my parameters as well (=Parameters!myparam1.Value) decalred using Report Window.

The plan is to load the report after I click a button. But the error occurs right when its trying to setParameters. Here is the code :

private void button4_Click(object sender, EventArgs e)
{
  ReportViewer reportViewer1 = new ReportViewer();
  reportViewer1.LocalReport.ReportPath = "AddressLabelReport.rdlc";
  reportViewer1.ProcessingMode = ProcessingMode.Local;
  reportViewer1.LocalReport.SetParameters(new ReportParameter[] { new ReportParameter  ("myparam1", "my value1", false), new ReportParameter("myparam2", "my value2", false) }); 
  reportViewer1.RefreshReport();
}

Here is the StackTrace :

Microsoft.Reporting.WinForms.LocalProcessingException was unhandled
  Message="An error occurred during local report processing."
  Source="Microsoft.ReportViewer.WinForms"
  StackTrace:
       at Microsoft.Reporting.WinForms.LocalReport.CompileReport()
       at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
       at TextBookLabelForm.Form1.button4_Click(Object sender, EventArgs e) in C:\Projects\TextBookLabelForm\TextBookLabelForm\Form1.cs:line 204
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at TextBookLabelForm.Program.Main() in C:\Projects\TextBookLabelForm\TextBookLabelForm\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

Any help is appriciated. Thank you.

3
  • Is there an inner exception that you could get more information from? I'd guess the problem would be with the parameters though. Commented Aug 1, 2012 at 23:37
  • I'm not sure this is related to your exception, but also note that you need to set the data sources for the report as well, e.g. reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("NameOfDataSourceHere", someDataTableIveLoaded)) Commented Aug 2, 2012 at 4:57
  • For now, I am not loading any data from table onto the report. All I need is just to print some string object. Commented Aug 2, 2012 at 13:56

3 Answers 3

2

The most likely problem asides programmer error is the backward compatibility of versions of reportviewer. The workaround is usually necessary every time you edit the report using the GUI.

  1. Open the report (.rdlc) file by right-clicking on the file in solutions explorer. Then select, "Open With..." Select XML (Text) Editor. (The report is opened as an XML document.

  2. Locate the tag and ensure it points to your older version's namespace. (Usually, it's the year in the namespace definition you have to change here. I changed mine to 2008. I think that's what VS2010 to VS2015 used.)

  3. Next, locate the ReportSections, and its corresponding child ReportSection tags. Delete these elements (tags) and their corresponding closing tags i.e. /ReportSections, /ReportSection

  4. Then locate ReportParametersLayout and delete it and its inner content.

  5. Save the update and run the program again. The report should work.

Sign up to request clarification or add additional context in comments.

Comments

1

Yoy may use like this to use this parameters. Try this one it will definitely help you

ReportParameter[] parms = new ReportParameter[n];
parms[0] = new ReportParameter("myparam1", "my value1");
parms[1] = new ReportParameter("myparam2", "my value2");
this.reportViewer1.LocalReport.SetParameters(parms);
this.reportViewer1.RefreshReport();

Comments

1

Try checking your parameter names in your report. If you add them with a different name it will throw that exception. It also throws this exception when your report is invalid, though I doubt this is the case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.