dotnet / winforms

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

Assembly.GetType Throws Exception When Using ControlDesigner in Netcore using Microsoft SDK #11566

Open ChidanandMurugaiah opened 1 week ago

ChidanandMurugaiah commented 1 week ago

Environment

Visual Studio - Version 17.10.1 Edition - Windows 11 Enterprise Version - 23H2 OS build - 22631.3737

.NET version

Net8.0, Net7.0, Net6.0

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

It works without the Microsoft.Winforms.Designer.SDK. It works properly in netframework.

Issue description

We are implementing smart tags for .NET Core controls and have installed the Microsoft.WinForms.Designer.SDK. However, when attempting to call the Assembly.GetCallingAssembly() method and subsequently the Assembly.GetType() method, a System.Reflection.ReflectionTypeLoadException is thrown.

Below code causes the exception Assembly callingAsm = Assembly.GetCallingAssembly(); Type[] asmTypes = callingAsm.GetTypes();

Sample - ControlDesigner_Exception.zip

Exception Image image

Steps to reproduce

1.Drag and drop the control CustomButton control from the Toolbox. 2.Run the sample.

Expected behavior: - Need to run without exception.

Diagnostics

No response

elachlan commented 1 week ago

@Olina-Zhang can your team please test when you can?

John-Qiao commented 5 days ago

@elachlan we can repro this issue from .NET 6.0 to the latest .NET 9.0 P7, the exception result and repro steps all are same as the provided in initial issue.

KlausLoeffelmann commented 3 days ago

Couple of questions:

Thanks!

John-Qiao commented 3 days ago

@KlausLoeffelmann