-2

I am using a third-party nuget package in my WPF project, on .NET 5. When I am trying to call some code, I get such message: reference to UserControl

Severity    Code    Description Project File    Line    Suppression State
Error   CS0012  The type 'UserControl' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.    

A third-party WPF library references Winforms Class named UserControl.

When I click on yellow-red icon to automatically resolve issue a Reference Manager window opens... I checked StackOverflow and did not find a similar situation. So, what do I do next? How do I add reference to Winforms library to WPF project on .NET 5?

Ivan P.
  • 832
  • 2
  • 9
  • 26
  • To be more specific, mRenderCtrl is of type AnyCAD.WPF.RenderControl, which is `RenderControl : UserControl, IComponentConnector`, in `namespace AnyCAD.WPF`. View3D is of class `RenderControl : System.Windows.Forms.UserControl` which is in `namespace AnyCAD.Forms` – Ivan P. Aug 28 '21 at 07:19

1 Answers1

0

I found it:

Add reference of System.Windows.forms in .Net Core

So, I had to add this line to my project file:

    <UseWindowsForms>true</UseWindowsForms>
Ivan P.
  • 832
  • 2
  • 9
  • 26