DispatchProxy
cannot work with types from collectible assemblies.
#62050
Labels
Milestone
DispatchProxy
cannot work with types from collectible assemblies.
#62050
Description
The
System.Reflection.DispatchProxy
type creates its types in anAssemblyBuilder
created withAssemblyBuilderAccess.Run
, leading to not just a resource leak whenDispatchProxies
with collectible types are used, but a total inability, because "[a] non-collectible assembly may not reference a collectible assembly".Reproduction Steps
I wrote the following demo that tests the unloadability of an ALC:
Expected behavior
Actual behavior
Regression?
No
Known Workarounds
Use non-collectible ALCs.
Configuration
Tested in .NET 5, the relevant code did not change in 6.
Other information
The logic around creating
AssemblyBuilders
needs to change; I will try to do it in the future.The text was updated successfully, but these errors were encountered: