【问题标题】:How to Fix the bug Local processing Exception was unhandled when passing parameter to report rdlc winform?如何修复传递参数报告rdlc winform时本地处理异常未处理的错误?
【发布时间】:2021-01-07 23:25:02
【问题描述】:

我正在做大学项目。在那,他们想要一个真正的证书。为此,我打算将TextBox 字符串传递给报告。

我搜索过在 winform 中传递参数。然后我一步一步地得到了这个过程。我实现了。

步骤:

1:在 Visual Studio 2010 中,打开您的 .rdlc 文件,然后打开“报告数据” 窗口(如果你看不到这个 窗口,进入查看菜单打开它);

2:右键单击“参数”节点, 并添加一个新参数,即:命名它 “内容”;

3:在您的 .rdlc 文件中,添加一个文本框, 将其命名为 tbContent,并设置其字段 快递到:

=Parameters!content.Value

4:转到您的表单文件,其中包括 你的reporterview控件,并添加 以下代码:

       this.reportViewer1.LocalReport.ReportEmbeddedResource

= “TestReport.Report1.rdlc”; ReportParameter rp = new ReportParameter(“内容”, this.textBox1.Text); this.reportViewer1.LocalReport.SetParameters(新 报告参数[] { rp }); this.reportViewer1.RefreshReport();

5:那么就可以传参数了 从表单上的 TextBox 到 .rdlc 文件;

我添加了using Microsoft.Reporting.WinForms; 程序集参考。

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

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

但它会抛出异常:

本地处理异常是 未处理
this.reportViewer1.LocalReport.SetParameters(新 报告参数[] { rp }); 行。

这是剪贴板中的完整错误:

  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: 

【问题讨论】:

  • 我昨天晚上开始搜索这个问题的解决方案。我读了很多这样的问题。这个问题影响了很多人。(主要是vb.net)其中一个肯定得到了解决方案。但他们没有分享。我继续搜索。

标签: c# winforms


【解决方案1】:

设置这个:

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

然后改变这个:

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

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

【讨论】:

  • 如果 rdlc 中的某些表达式有错误或者您想读取空参数值,或者 rdl 文件中存在任何语法错误或运行时错误都可能导致此错误,如果我有您的 rdlc 文件可以帮助您更多
【解决方案2】:

以防万一,我在重新组织项目文件夹后遇到了同样的问题,因此更改了报告文件路径。我所要做的就是在 ReportViewer 的选择报表组合框中重新选择报表,该组合框可从其右上角访问。

【讨论】:

    【解决方案3】:

    还要仔细检查您的rdlc 文件名的拼写是否正确。例如,我的报告文件是ReportName.rdlc,但我输入了this.reportViewer1.LocalReport.ReportPath = "ReportsName.rdlc";

    【讨论】:

      【解决方案4】:

      您可以很好地使用嵌入式,只是不要忘记在 RDLC 路径中包含名称空间。程序集命名空间以及您可能拥有的任何可能的子命名空间作为报告的完整命名空间路径都是必需的。

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

      reportViewer1.LocalReport.ReportEmbeddedResource = "assemblyname.subnamespace.Report1.rdlc"
      

      【讨论】:

        【解决方案5】:

        我刚刚在“NuGet 包管理器控制台”中运行Install-Package Microsoft.SqlServer.Types,一切正常。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-12-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多