ReportViewer - MethodAccessException

0

Good afternoon,

I use the VisualStudio 2015 Community on a Windows 10x64 and am encountering the following problem when running the debug of a Windows Form Application project:

    System.MethodAccessException was unhandled
  HResult=-2146233072
  Message=Falha no método 'Microsoft.Reporting.WinForms.LocalReport..ctor()' ao tentar acessar o método 'Microsoft.ReportingServices.StandalonePreviewStore..ctor()'.
  Source=Sistema
  StackTrace:
       em Microsoft.Reporting.WinForms.LocalReport..ctor() na C:\Projetos\VisualStudio\Sistema\Sistema\Beans\GuiaSadt.cs:linha 0
       em Microsoft.Reporting.WinForms.ReportViewer.CreateLocalReport() na C:\Projetos\VisualStudio\Sistema\Sistema\Beans\GuiaSadt.cs:linha 0
       em Microsoft.Reporting.WinForms.ReportViewer.Reset() na C:\Projetos\VisualStudio\Sistema\Sistema\Beans\GuiaSadt.cs:linha 0
       em Microsoft.Reporting.WinForms.ReportViewer..ctor() na C:\Projetos\VisualStudio\Sistema\Sistema\Beans\GuiaSadt.cs:linha 0
       em Sistema.FrmPrincipal.FrmPrincipal_Load(Object sender, EventArgs e) na C:\Projetos\VisualStudio\Sistema\Sistema\FrmPrincipal.cs:linha 181
       em System.Windows.Forms.Form.OnLoad(EventArgs e)
       em System.Windows.Forms.Form.OnCreateControl()
       em System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       em System.Windows.Forms.Control.CreateControl()
       em System.Windows.Forms.Control.WmShowWindow(Message& m)
       em System.Windows.Forms.Control.WndProc(Message& m)
       em System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       em System.Windows.Forms.Form.WmShowWindow(Message& m)
       em System.Windows.Forms.Form.WndProc(Message& m)
       em System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  InnerException: 

I'm using the ReportViewer Control inside a Form with nothing else on it and this error happens.

Is there any missing reference or configuration in my project? Thankful.

EDIT: Where the error occurs is the following snippet:

this.reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer();
    
asked by anonymous 17.03.2016 / 18:33

1 answer

0

The problem that was occurring was with ILMerge. Home Because ILMerge merges with .exe the DLL's used by the project ReportViewer did not find the reference what caused the error. Home Removing ILMerge from the project is all up and running again.

    
24.03.2016 / 14:45