dotnet / winforms

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

Issue with .Net Framework out-of-process designer. Cannot Add 32-bit Controls to Toolbox #10162

Open DelmerJohnson opened 1 year ago

DelmerJohnson commented 1 year ago

Environment

VS 2022 (v. 17.8.0 Preview 4.0). My current project is set to use the .Net Framework 4.8.1. This is the only area to submit issues with an out-of-process designer that I can see right now.

.NET version

4.8.1 (but would also like to do with with Framework 4.7.2)

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

Yes! It works fine in Visual Studio 2019.

Issue description

I primarily develop solutions for Microsoft Dynamics SL as an ISV. Using the out-of-process designer with the current preview of VS 2022 (v. 17.8.0 Preview 4.0 according to Help > About), I can view the SL SDK 32-bit controls on the design surface, reposition, and save them using a project initially created with VS 2019. I cannot load and view the project in the current release version (17.7.5) without seeing many yellow error messages stating “Could not find type…”. This is a welcome improvement! However, I cannot add the 32-bit controls to the Toolbox. When I try to add the Microsoft.Dynamics.SL.Controls.dll to the toolbox using “Choose Items…” after browsing on the .Net Framework Components tab, I see an error message stating “The file ‘C:\Program Files (x86)\Common Files\Microsoft Shared\DynamicsSL\Microsoft.Dynamics.SL.Controls.dll’ is not valid.” Please make is possible to add this, and other valid 32-bit dlls containing .Net Framework Component controls to the toolbox. Without this I can’t add new SL SDK controls to the form when they are required.

Steps to reproduce

When I try to add the Microsoft.Dynamics.SL.Controls.dll to the toolbox using “Choose Items…” after browsing on the .Net Framework Components tab, I see an error message stating “The file ‘C:\Program Files (x86)\Common Files\Microsoft Shared\DynamicsSL\Microsoft.Dynamics.SL.Controls.dll’ is not valid.”

Diagnostics

No response

Tanya-Solyanik commented 1 year ago

@Olina-Zhang - do we have this bug in the designer repo already?

Olina-Zhang commented 1 year ago

@Tanya-Solyanik, I tried to create a Winforms control library application in VS 2019, and build it with platform: x86 to generate dll. In VS 2019, create a Winforms .net framework application(Classic designer), and import that dll by toolbox using “Choose Items…”, it is successful, and in VS 2022, do the same thing in Winforms .net framework application(Classic designer, not out-of-process designer), it gets an error about assembly is not valid. Please see following result:

VS 2019: VS2019

VS 2022: VS2022

It seems a known issue about 32bit references, internal AzDo bug: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1434297, feedback ticket: https://developercommunity.visualstudio.com/t/WinForms-NET-Framework-Projects-cant-d/1601210, is it right?

Tanya-Solyanik commented 1 year ago

@Olina-Zhang - thank you, yes, the root cause is the same, but this issue also mentions addition of controls to the toolbox. I thought that we could add controls from 32 bit assemblies to the toolbox in the Core Designer. I know that "Choose Items" dialog is broken, but if we add a reference to the project, I expected that all controls from that reference are added to the toolbox. I think the test should look like this:

  1. create a 32bit Core library with a UserControl, build it
  2. create a 32bit Core exe
  3. add the library to the exe as a reference
  4. Activate the Form in the OOP designer Does library's UserControl show up in the toolbox? What happens in the OOP .NET Framework designer in the same scenario, can we use it as a workaround?
Olina-Zhang commented 1 year ago

@Tanya-Solyanik I followed the scenarios you provided, it also doesn't work.

  1. Create a 32bit Core library with a UserControl by change platform to x86(need to install .Net x86 SDK build), build it --- it generates 32bit library in x86 folder
  2. Create a Winforms .Net application or .Net framework application with enable OOP designer, then add the 32bit library as a reference to this winforms application

Current result: No UserControl shows up in the ToolBox after added that library for Winforms .Net application or .Net framework application with enable OOP designer

DelmerJohnson commented 11 months ago

This continues to be an issue in Visual Studio 2022 17.9.0 Preview 2. Thanks for the excellent visual illustrations above!