Skip to content

Invalid handle passed to RuntimeTypeHandle.GetRuntimeTypeFromHandle when calling a synchronized method in a collectible assembly in .NET 10 #117566

@agocke

Description

@agocke

Description

Regression in .NET 10 (not sure which preview).

The repro is a VB DLL being loaded into a collectible ALC. If collectible is disabled, this stops reproing on my machines (Mac & Linux)

Reproduction Steps

repro 2.zip

Expected behavior

No exception

Actual behavior

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for 'vb.C1' threw an exception.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.RuntimeTypeHandle.GetRuntimeTypeFromHandle(IntPtr handle)
   at vb.C1.set_a(C1 WithEventsValue)
   at vb.C1..cctor() in /Users/andy/Downloads/repro 2/vb/Program.vb:line 2
   --- End of inner exception stack trace ---
   at vb.C1.get_a()
   at vb.C1.Main() in /Users/andy/Downloads/repro 2/vb/Program.vb:line 5
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Program.<Main>$(String[] args) in /Users/andy/Downloads/repro 2/cs/Program.cs:line 7

Regression?

Yes

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions