Closed CortiWins closed 5 months ago
@Olina-Zhang can your team please test this?
@CortiWins this issue can be resolved using Nuget: Microsoft.WinForms.Designer.SDK, and need to refactor the namespaces from System.Windows.Forms.Design.ParentControlDesigner to Microsoft.DotNet.DesignTools.Designers.ParentControlDesigner, referring to blog: https://devblogs.microsoft.com/dotnet/custom-controls-for-winforms-out-of-process-designer/
@KlausLoeffelmann maybe we should add an analyzer for this?
Okay, so using Microsoft.WinForms.Designer.SDK solved it for me, but required one more change to the codebase.
And for future searchers and finders of this topic: While the Assembly containing the System.Windows.Forms.Design.ParentControlDesigner is available during runtime, the assembly that contains Microsoft.DotNet.DesignTools.Designers.ParentControlDesigner is not.
This means, that Reflection that resolves all included Type-dependencies ( like Assembly.GetTypes() ) on the assembly that contains the designer-class will now lead to a "file not found" exception during runtime.
I think we'd want to put this analyzer in our Designer SDK rather than here, so @Olina-Zhang can you please take a moment to create an issue in the designer repo to track the suggestion if we don't have it already?
@merriemcgaw filed GH DT https://github.com/microsoft/winforms-designer/issues/6002 to track this.
Environment
Version 17.10.2
.NET version
.Net 8.0
Did this work in a previous version of Visual Studio and/or previous .NET release?
Net Framework 4.8 and earlier
Issue description
I tracked down issues with much more complicated controls (including crashing visual studio) to the minimum example attached. This exact code works in Net4.8 but does not in Net8/7. The designer class derived fromParentControlDesigner is neither instanced nor initialized.
The UserControl
The Designer
This solution contains projects for net4.8 and Net8 for a direct comparison UserControlDesignerIsNotCalledExample.zip
Steps to reproduce
The attached project contains the code to reproduce the discreprancy between net4.8 and Net8.
Diagnostics
No response