Skip to content

Conversation

@ryalanms
Copy link
Member

@ryalanms ryalanms commented Jul 27, 2021

Description

Backport fix from 6.0 to 5.0: Compilation error MC3064 when importing internal user control from signed class library.

Use reflection-only context for InternalsVisibleToAttribute type comparison.

Fixes Issue #2492: Compilation error MC3064 when importing internal user control from signed class library. The wrong load context was used for a type comparison that always failed.

Customer Impact

Internal types contained in assemblies with InternalsVisibleTo attributes that are referenced in markup cause a markup compiler error: error MC3064: Only public or internal classes can be used within markup. 'InternalClass' type is not public or internal.

Regression

This is a regression from .NET Framework.

Risk

Very low. This code is only exercised when WPF applications are compiled. This is a single-line change that has been in .NET 6.0 since February.

Testing

Repro'd the issue on release/5.0 when importing an internal user control from signed class library:

error MC3064: Only public or internal classes can be used within markup.

After applying the fix and rebuilding the WindowsDesktop SDK, referencing internal types in markup that are contained in an assembly with InternalsVisibleTo (which grants access to the target assembly) now works as expected when targeting .NET 5.0.

@ryalanms ryalanms requested a review from a team as a code owner July 27, 2021 23:39
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jul 27, 2021
@ghost ghost requested review from SamBent and fabiant3 July 27, 2021 23:39
@leecow leecow added this to the 5.0.11 milestone Aug 3, 2021
@ryalanms ryalanms merged commit 405e0b9 into release/5.0 Aug 9, 2021
@vishalmsft vishalmsft deleted the backport.signedclasslibrary.fix branch February 10, 2022 06:04
@ghost ghost locked as resolved and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage Servicing-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants