Cannot use GetRequiredService<>() when using microsoft.winforms.designer.sdk\1.6.0 #13296
Labels
area-VSDesigner
Windows Forms out-of-proc designer related issues
Milestone
WinFormsApp1.zip
Environment
Version 17.13.6
.NET version
.NET 8
Did this work in a previous version of Visual Studio and/or previous .NET release?
No response
Issue description
Using the package microsoft.winforms.designer.sdk make the method extension GetRequiredService<>() in Microsoft.Extensions.DependencyInjection unusable which leads to the following error when the application starts:
Steps to reproduce
I created a class library containing a winforms usercontrol with several components on it. One of those components (a panel) acts as a docking container, so I included microsoft.winforms.designer.sdk and inherited a class from the ParentControlDesigner.
This just works fine and I have no complaints about this.
So, next I created a winforms application using a hostbuilder. To resolve 'form1' I use GetRequiredService() and this is where it stops working.
GetRequiredService<>() is ambiguous. It's defined in Microsoft.Extensions.DependencyInjection (the one I want to use) but also in the system namespace (declared in Microsoft.WinForms.Utilities.Shared.dll).
The problem is that this dll file is never loaded when I start the application.
So when I start the application I get the load exception.
I've have included a bare-mimimal project to reproduce this error.
Diagnostics
The text was updated successfully, but these errors were encountered: