Как исправить ошибку Локальная обработка Исключение было необработанным при передаче параметра в отчет rdlc winform? - PullRequest
4 голосов
/ 09 июня 2011

Я занимаюсь проектом колледжа.В этом они хотят добросовестный сертификат.Для этого я планировал передать строку TextBox в отчет.

Я гуглил для передачи параметра в winform.Тогда я получил этот пошаговый процесс.Я реализую это.

Шаг:

1: В Visual Studio 2010 откройте файл .rdlc и откройте окно «Данные отчета» (Если вы не видите это окно,перейдите в меню «Вид», чтобы открыть его);

2: щелкните правой кнопкой мыши узел «Параметры» и добавьте новый параметр, то есть: назовите его «content»;

3: В вашем.файл rdlc, добавьте текстовое поле, назовите его tbContent и установите для его выраженного поля значение:

= Параметры! content.Value

4: Перейдите к файлу формы, в котором содержится элемент управления reporterview, идобавьте следующий код:

       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: затем вы можете передать параметр из 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 (new ReportParameter [] {rp});line.

Вот полная ошибка из буфера обмена:

  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: 

Ответы [ 3 ]

3 голосов
/ 10 июня 2011

Установите это:

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

И измените это:

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

на

this.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
1 голос
/ 11 июля 2012

На всякий случай, у меня была такая же проблема после того, как я реорганизовал папки своего проекта, таким образом изменив путь к файлу отчета. Все, что мне нужно было сделать, - это повторно выбрать отчет в ComboBox «Выбрать отчет ReportViewer», доступный из его верхнего правого угла.

0 голосов
/ 12 декабря 2017

также дважды проверьте правильность написания вашего rdlc имени файла. Например, мой файл отчета был ReportName.rdlc, но я набрал this.reportViewer1.LocalReport.ReportPath = "ReportsName.rdlc";

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...