reportviewer winform.dll error

Sushil Agarwal 381 Reputation points
2022-09-25T07:13:30.163+00:00

Dear experts i am getting error

[A]Microsoft.Reporting.WinForms.ReportViewer cannot be cast to [B]Microsoft.Reporting.WinForms.ReportViewer. Type A originates from 'Microsoft.ReportViewer.WinForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'LoadNeither' at location 'C:\Users\Sushil\AppData\Local\Microsoft\VisualStudio\16.0_7e5134cc\ProjectAssemblies\n2tpl1_y01\Microsoft.ReportViewer.WinForms.dll'. Type B originates from 'Microsoft.ReportViewer.WinForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'LoadFrom' at location 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\SSAS\Microsoft.ReportViewer.WinForms.dll'.

i have installed nuget reporting service
NuGet\Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms -Version 150.1537.0

I am using vs2022 community edition and use vs2019 for ssrs projects

can some body please guide how to resolve above error ?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,828 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,799 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Joyzhao-MSFT 15,566 Reputation points
    2022-09-26T07:06:13.283+00:00

    Hi anonymous userAgarwal-8271 ,
    You must ensure that every reference to the report viewer is the same. You need to delete the reference to the old report viewer control and add the new reference. You can refer to this article: https://stackoverflow.com/questions/42529104/failed-to-create-component-reportviewer-the-error-message-follows-system-run
    Then you can try to use the new report viewer control in your application.
    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.