Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChidanandMurugaiah opened this issue Jun 20, 2024 · 4 comments
Assignees
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues untriaged The team needs to look at this issue in the next triage

Comments

@ChidanandMurugaiah
Copy link

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

@ChidanandMurugaiah ChidanandMurugaiah added the untriaged The team needs to look at this issue in the next triage label Jun 20, 2024
@elachlan elachlan added the area-VSDesigner Windows Forms out-of-proc designer related issues label Jun 20, 2024
@elachlan
Copy link
Contributor

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

@John-Qiao
Copy link
Member

@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
Copy link
Member

KlausLoeffelmann commented Jun 25, 2024

Couple of questions:

  • Is this a runtime or a design-time issue? So, does this exception happen when you start the up or when you are trying to add the new control to the Form?
  • Just to make sure, I understand the scenario: Why do you need to call those methods in constructor?

Thanks!

@KlausLoeffelmann KlausLoeffelmann self-assigned this Jun 25, 2024
@John-Qiao
Copy link
Member

@KlausLoeffelmann

  • It's a runtime issue, so this exception occurs when start the project.
  • This exception does not occur when call those methods in Form load event or other control events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues untriaged The team needs to look at this issue in the next triage
Projects
None yet
Development

No branches or pull requests

4 participants