Skip to content

Upgrading to .NET 10 and Harmony 2.4.2 causes an error when debugging in Debug configuration #749

@ImoutoChan

Description

@ImoutoChan

Describe the bug
After upgrading to .NET 10 and updating the package to
<PackageVersion Include="Lib.Harmony" Version="2.4.2"/>,
starting a debug session using the Debug configuration in Rider results in the following exception:

System.ExecutionEngineException: Exception of type 'System.ExecutionEngineException' was thrown

This exception contains no stack trace. However, the console outputs the following error:

Fatal error.
Internal CLR error. (0x80131506)
   at MonoMod.Core.Interop.CoreCLR+V60.InvokeCompileMethod(IntPtr, IntPtr, IntPtr, CORINFO_METHOD_INFO*, UInt32, Byte**, UInt32*)
   at MonoMod.Core.Platforms.Runtimes.Core60Runtime+JitHookDelegateHolder.CompileMethodHook(IntPtr, IntPtr, CORINFO_METHOD_INFO*, UInt32, Byte**, UInt32*)
   at System.Runtime.CompilerServices.StaticsHelpers.<GetThreadStaticsByIndex>g____PInvoke|0_0(System.Runtime.CompilerServices.ByteRefOnStack, Int32, Int32)
   at System.Runtime.CompilerServices.StaticsHelpers.GetThreadStaticsByIndex(System.Runtime.CompilerServices.ByteRefOnStack, Int32, Boolean)
   at System.Runtime.CompilerServices.StaticsHelpers.GetGCThreadStaticsByIndexSlow(Int32)
   at System.Runtime.CompilerServices.StaticsHelpers.GetThreadLocalStaticBaseByIndex(Int32, Boolean)
   at System.Runtime.CompilerServices.StaticsHelpers.GetGCThreadStaticBase(System.Runtime.CompilerServices.MethodTable*)
   at System.Windows.Threading.Dispatcher..ctor()
   at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
   at System.Windows.Freezable..ctor()
   at System.Windows.Media.Imaging.BitmapSource..ctor(Boolean)
   at [my code]
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
   at [my code]
   at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

Runtime environment (please complete the following information):

  • OS: Windows 10, 64bit
  • .NET version 10
  • Harmony version 2.4.2

Additional context

  • Everything works fine without debugging even in Debug configuration (dotnet run -c Debug).
  • Debugging session in the Release configuration profile works fine as well.

I tried replacing:
<PackageVersion Include="Lib.Harmony" Version="2.4.2"/>
with

<PackageVersion Include="Lib.Harmony.Thin" Version="2.4.1" />
<PackageVersion Include="MonoMod.Core" Version="1.3.3" />

and it also helped.

So it only reproduces for me in Debug configuration with debugger attached from the start

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions