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

Running the control fails, displaying "The type 'IHandle<>' is defined in an assembly that is not referenced" #10661

Closed
Nora-Zhou01 opened this issue Jan 15, 2024 · 7 comments
Assignees
Labels
💥 regression-preview Regression from a preview release
Milestone

Comments

@Nora-Zhou01
Copy link
Member

Nora-Zhou01 commented Jan 15, 2024

.NET version

9.0.100-alpha.1.24062.11

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes

Issue description

Running the control fails, displaying "The type 'IHandle<>' is defined in an assembly that is not referenced."
In the latest .Net 9.0 SDK build: 9.0.100-alpha.1.24062.11, an exception pops up:

The type 'IHandle<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.Windows.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

9.0.mp4

Steps to reproduce

  1. Create a Winforms .Net application
  2. Add a NumericUpDown control to form designer
  3. Build and run application

More info:

  1. There is a workaround: manually add "System.Private.Windows.Core.dll" to the project. The project can run normally
  2. This issue occurs in the following controls: NumericUpDown, TrackBar, Process, DataGridView, PictureBox, SplitContainer
@Nora-Zhou01 Nora-Zhou01 added untriaged The team needs to look at this issue in the next triage 💥 regression-preview Regression from a preview release labels Jan 15, 2024
@JeremyKuhne JeremyKuhne self-assigned this Jan 16, 2024
@JeremyKuhne
Copy link
Member

JeremyKuhne commented Jan 16, 2024

Hmm. Happens when you cast any control to any interface, but not when you cast to base classes. Not what I would have expected.

@jaredpar do you know why casting to a public interface needs an explicit reference to an assembly where an internal interface is defined? Is this expected?

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error	CS0012	The type 'IHandle<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.Windows.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.	WinFormsApp5	C:\Users\jkuhne\source\repos\WinFormsApp5\WinFormsApp5\Form1.Designer.cs	32	N/A	

IHandle<T> is on the type, but it is internal, as is it's T. Is this possibly related to InternalsVisibleTo?

@jaredpar
Copy link
Member

do you know why casting to a public interface needs an explicit reference to an assembly where an internal interface is defined?

If the public interface implements the internal interface then it's possible the compiler may pull on that when trying to resolve the symbols.

Is this expected?

In general if you perform compilations where you do not give the compiler the full reference graph you are playing with fire. While the compiler is careful to not traverse symbols unless it needs to it is sometimes necessary. Bug fixes, new features, etc ... can always force us to look a bit deeper on existing symbols and thus pull in more assembly references. This can break existing code which only gave the compiler a partial reference graph. Such behavior changes are considered "by design" / "won't fix" bugs though. If we could go back in time and fail compilations that didn't provide full reference graphs we'd strongly consider doing so to avoid issues like this.

@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label Jan 16, 2024
@elachlan
Copy link
Contributor

Fixed by #10673

@MandiMan
Copy link
Contributor

MandiMan commented Jan 19, 2024

@JeremyKuhne @elachlan verified on .NET 9.0.100-alpha.1.24068.28 + latest dlls from Winforms Repo of main branch, it is not fixed. Running the control still fails, displaying "The type 'IHandle<>' is defined in an assembly that is not referenced."

10661.mp4

@JeremyKuhne
Copy link
Member

JeremyKuhne commented Jan 19, 2024

@MandiMan 24069.3 is the first SDK build to include the fix

@MandiMan
Copy link
Contributor

Verified this on .NET 9.0.100-alpha.1.24070.3, issue was fixed. Running the control was successful.

10661.mp4

@Olina-Zhang Olina-Zhang added this to the 9.0 Preview1 milestone Jan 23, 2024
@Eudora-Li01
Copy link
Contributor

Verified this issue with .NET 9 Preview 1 test pass build, it was fixed. Test result is same as above.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💥 regression-preview Regression from a preview release
Projects
None yet
Development

No branches or pull requests

8 participants