dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.42k stars 984 forks source link

VS 17.4 designer can't load any user control referenced by dll #8327

Closed kirsan31 closed 1 year ago

kirsan31 commented 1 year ago

Environment

Microsoft Visual Studio Community 2022 Version 17.4.2 VisualStudio.17.Release/17.4.2+33122.133 Microsoft .NET Framework Version 4.8.04084

.NET version

.Net6, .Net7

Did this work in a previous version of Visual Studio and/or previous .NET release?

Yes in all version before 17.4 Preview 2.0.

Issue description

Any form that uses user control referenced by dll in project settings will not open with error (could not load the assembly), or open without this control on the form. Error: image

Empty designer without error: Snipaste_2022-12-05_14-40-03

Same reports: https://github.com/kirsan31/winforms-datavisualization/issues/4 Here we naively thought that the problem concerns only chart control...

https://developercommunity.visualstudio.com/t/1740-NET6-WinForms-designer-regress/10198799#T-N10221437

https://github.com/dotnet/winforms/issues/8287 related?

Steps to reproduce

Any form with any user control. Here test project: WinFormsDesignerRefBug.zip

Open WinFormsDesignerRefBug\WinFormsApp1\WinFormsApp1.sln rebuild and try to open designer - you will see empty form.

If in example above we will create Form2, add our control to it, then derive Form1 from Form2: public partial class Form1 : Form2 then we will see Could not load file or assembly error in designer.

Lots of discussion on this bug was in https://github.com/kirsan31/winforms-datavisualization/issues/4 but without any result :(

Diagnostics

fail: Request failures: Sessions/InitializeRootComponent.
                        Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Could not load file or assembly 'WinFormsControlLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
dreddy-work commented 1 year ago

@Tanya-Solyanik / @Shyam-Gupta , can you guys take a look if this is solved with recent @Tanya-Solyanik fix and need to be serviced furher? @merriemcgaw as FYI.

Tanya-Solyanik commented 1 year ago

Yes, this is a HintPath case, it had been serviced in the latest update for 17.4.

    <ItemGroup>
        <Reference Include="WinFormsControlLibrary1">
            <HintPath>..\WinFormsControlLibrary1\bin\$(Configuration)\$(TargetFramework)\WinFormsControlLibrary1.dll</HintPath>
        </Reference>
    </ItemGroup>
Tanya-Solyanik commented 1 year ago

Fix is in the pipeline targeting the December patch Tuesday for VisualStudio 2022 17.4 image