Adding reference to System.Windows.Forms.Integration in a WPF app
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Adding-reference-to-SystemWindowsForms/10941610)._
---
[severity:It's more difficult to complete my work]
[WinFormsNuGet.zip](https://aka.ms/dc/file?name=Be241d7135ef140289d996bd7f798b793638888561083255355_WinFormsNuGet.zip&tid=e241d7135ef140289d996bd7f798b793638888561083255355)
The attached solution is an empty Win Forms control created by the VS and a nearly empty default WPF app which adds the control using <wfi:WindowsFormsHost>
WinFormsNuGet\WpfApp\MainWindow.xaml(13,10): error MC3074: The tag 'WindowsFormsHost' does not exist in XML namespace 'clr-namespace:System.Windows.Forms.Integration;assembly=System.Windows.Forms.Integration'. Line 13 Position 10.
The problem is that the reference
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=System.Windows.Forms.Integration"
does not really work. I see "Assembly ... was not found" error on it when I point the mouse.
The first thing is that the above error is wrong. It suggests that the assembly has been loaded.
The attached project is the exact solution which was suggested by the https://developercommunity.visualstudio.com/t/SystemWindowsFormsIntegation/683788 and which referred to https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf-by-using-xaml
It does not work.
It does work if I use References > Add Project reference (Why project reference BTW?) > Browse > and select
C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.18\ref\net8.0\WindowsFormsIntegration.dll
It is kind of awkward and error prone manual work. We do not want to suggest this to users of our control.
There is no NuGet package for the assembly.
It seems that the <UseWindowsForms>true</UseWindowsForms> was supposed to resolve the reference automatically, but someone did not finish the work.
I thought NuGet was designed to avoid unsafe browse for dll way of adding refs?
Thanks
Nikolai
---
### Original Comments
#### Feedback Bot on 7/24/2025, 08:53 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Contributor guide
Assessment
This issue has not been assessed yet.