Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Fix the bug Local processing Exception was unhandled when passing parameter to report rdlc winform?

Tags:

c#

winforms

I am doing college project. In that, they want a bonafide certificate. For that, I planned to pass TextBox string to report.

I googled for passing parameter in a winform. Then I got this step by step process. I implement that.

Step:

1: In Visual Studio 2010, open your .rdlc file, and open “Report Data” window (If you can not see this window, go to View menu to open it);

2: Right click the “Parameters” node, and add a new Parameter, ie: named it “content“;

3: In your .rdlc file, add a textbox, named it tbContent, and set its filed express to :

=Parameters!content.Value

4: Go to your Form file which include your reporterview control, and add the following code:

       this.reportViewer1.LocalReport.ReportEmbeddedResource

= “TestReport.Report1.rdlc”; ReportParameter rp = new ReportParameter(“content”, this.textBox1.Text); this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp }); this.reportViewer1.RefreshReport();

5: then you can pass the parameter from the TextBox on the form to .rdlc file;

I added using Microsoft.Reporting.WinForms; assembly reference.

 this.reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";

            ReportParameter rp = new ReportParameter("content", this.textBox1.Text);
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
            this.reportViewer1.RefreshReport();  

But it throws the exception:

Local processing Exception was unhandled at
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp }); line.

Here's the full error from the clipboard:

  Microsoft.Reporting.WinForms.LocalProcessingException was unhandled
  Message=An error occurred during local report processing.
  Source=Microsoft.ReportViewer.WinForms
  StackTrace:
       at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
       at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
       at Report.Form1.Form1_Load(Object sender, EventArgs e) in D:\Jagadeeswaran\Project\Report\Report\Form1.cs:line 38
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.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.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       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 Report.Program.Main() in D:\Jagadeeswaran\Project\Report\Report\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.ApplicationException
       Message=The report definition for report 'D:\Jagadeeswaran\Project\Report\Report\bin\Debug\~/Report1.rdlc' has not been specified
       Source=Microsoft.ReportViewer.Common
       StackTrace:
            at Microsoft.Reporting.PreviewStore.GetCompiledReport(CatalogItemContextBase context, Boolean rebuild, Byte[]& reportDefinition, ControlSnapshot& snapshot)
            at Microsoft.Reporting.LocalService.GetCompiledReport(CatalogItemContextBase itemContext, Boolean rebuild, ControlSnapshot& snapshot)
            at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
       InnerException: System.IO.DirectoryNotFoundException
            Message=Could not find a part of the path 'D:\Jagadeeswaran\Project\Report\Report\bin\Debug\~\Report1.rdlc'.
            Source=mscorlib
            StackTrace:
                 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
                 at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
                 at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
                 at Microsoft.ReportingServices.StandalonePreviewStore.GetReportDefinition(ReportID reportId)
                 at Microsoft.Reporting.PreviewStore.GetCompiledReport(CatalogItemContextBase context, Boolean rebuild, Byte[]& reportDefinition, ControlSnapshot& snapshot)
            InnerException: 
like image 541
Sagotharan Avatar asked Jun 09 '11 18:06

Sagotharan


3 Answers

Set this:

this.reportViewer1.ProcessingMode = 
    Microsoft.Reporting.WinForms.ProcessingMode.Local;

And change this:

this.reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc" 

to

this.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
like image 86
DeveloperX Avatar answered Nov 03 '22 20:11

DeveloperX


Just in case that this would be the case, I had the same problem after I reorganized my project folders, thus changing the report file path. All I had to do is re-selecting the report in the ReportViewer's Choose Report ComboBox accessible from its upper-right corner.

like image 21
Daniel Avatar answered Nov 03 '22 19:11

Daniel


also double check that you are spelling your rdlc filename correctly. For example, my report file was ReportName.rdlc but I had typed in this.reportViewer1.LocalReport.ReportPath = "ReportsName.rdlc";

like image 44
peroija Avatar answered Nov 03 '22 20:11

peroija