Skip to content

Fix DispatchProxy Generator Issues with AssemblyLoadContexts - #120157

Closed
afifi-ins wants to merge 1 commit into
dotnet:mainfrom
afifi-ins:DispatchProxyGeneraotor
Closed

afifi-ins wants to merge 1 commit into
dotnet:mainfrom
afifi-ins:DispatchProxyGeneraotor

Conversation

@afifi-ins

@afifi-ins afifi-ins commented Sep 26, 2025 •

Copy link
Copy Markdown

This PR fixes two scenarios where DispatchProxy behaves incorrectly when working with multiple AssemblyLoadContexts (ALCs).
Fixes:

  1. Corrects proxy generation where the second ALC could produce a proxy bound to the wrong interface type, leading to InvalidCastException.
  2. Fixes the case of creating a proxy when the base proxyType is in a non-collectable ALC (in this case the default ALC) and the interface is in a collectable ALC.

Added Unit test to prevent regressions.

Fixes: #109398

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 26, 2025
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 26, 2025
@afifi-ins
afifi-ins force-pushed the DispatchProxyGeneraotor branch from f77dbf4 to eb9aeaf Compare September 26, 2025 20:56
@jkotas jkotas added area-System.Reflection and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 26, 2025
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@github-actions github-actions Bot locked and limited conversation to collaborators Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Reflection community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DispatchProxy generates a proxy type implementing the interface from the wrong ALC

3 participants