Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch on .net 7&8 throw TypeLoadException while debugging #585

Closed
Muscipular opened this issue Feb 29, 2024 · 18 comments
Closed

Patch on .net 7&8 throw TypeLoadException while debugging #585

Muscipular opened this issue Feb 29, 2024 · 18 comments
Assignees
Labels

Comments

@Muscipular
Copy link

Describe the bug
when start debugger , patch will throw TypeLoadException:

System.TypeLoadException: Could not load type 'CORINFO_METHOD_INFO' from assembly 'System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo)
   at HarmonyLib.PatchProcessor.Patch()
   at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)

if without debugger, program work well.

Runtime environment (please complete the following information):

  • OS: Win10 24H2 64
  • .NET version 7 & 8 both
  • Harmony version 2.3.0
@pardeike
Copy link
Owner

pardeike commented Mar 1, 2024

Can you explain a little bit more? Please tell me how you debug your code, and if you use Harmony in the same project or on a different DLL so I can reproduce your case. I just need more details.

@Muscipular
Copy link
Author

HEAD.zip

here is sample project. i use rider open it and start with debug. and then, _harmony.Patch(action.Method, postfix: new HarmonyMethod(Hook)); throw that exception

@Muscipular
Copy link
Author

if you just run ConsoleApp1, it work well.

@pardeike
Copy link
Owner

pardeike commented Mar 2, 2024

I can confirm it with Visual Studio, Harmony 2.3 and net8 locally, ping @nike4613
Easy to reproduce with the provided project above. I even modified the source to double check for any schenaningans but it does give me a NRE in MonoMod's _Generate()

using HarmonyLib;

namespace ClassLibrary1;

public class Class1
{
	public static void A()
	{
		Console.WriteLine("Class1 A");
	}
}

public class Patch
{
	private static Harmony _harmony = new Harmony("Patch");

	public static void Do()
	{
		//var action = Class1.A;
		//_harmony.Patch(action.Method, postfix: new HarmonyMethod(Hook));

		var mA = SymbolExtensions.GetMethodInfo(() => Class1.A());
		var mHook = SymbolExtensions.GetMethodInfo(() => Patch.Hook());
		_harmony.Patch(mA, postfix: new HarmonyMethod(mHook));
	}

	public static void Hook()
	{
		Console.WriteLine("Hook");
	}
}
MonoMod.Common.dll!MonoMod.Utils.DMDEmitDynamicMethodGenerator._Generate(MonoMod.Utils.DynamicMethodDefinition dmd, object context)	Unknown
MonoMod.Common.dll!MonoMod.Utils.DMDGenerator<MonoMod.Utils.DMDEmitDynamicMethodGenerator>.Generate(MonoMod.Utils.DynamicMethodDefinition dmd, object context)	Unknown
MonoMod.Common.dll!MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.DetourRuntimeILPlatform()	Unknown
MonoMod.Common.dll!MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETPlatform.DetourRuntimeNETPlatform()	Unknown
MonoMod.Common.dll!MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform.DetourRuntimeNETCorePlatform()	Unknown
MonoMod.Common.dll!MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform.Create()	Unknown
MonoMod.Common.dll!MonoMod.RuntimeDetour.DetourHelper.Runtime.get()	Unknown
0Harmony.dll!HarmonyLib.HarmonySharedState.HarmonySharedState() Line 58	C#
[Native to Managed Transition]	
[Managed to Native Transition]	
0Harmony.dll!HarmonyLib.HarmonySharedState.GetPatchInfo(System.Reflection.MethodBase method) Line 112	C#
0Harmony.dll!HarmonyLib.PatchProcessor.Patch() Line 101	C#
0Harmony.dll!HarmonyLib.Harmony.Patch(System.Reflection.MethodBase original, HarmonyLib.HarmonyMethod prefix, HarmonyLib.HarmonyMethod postfix, HarmonyLib.HarmonyMethod transpiler, HarmonyLib.HarmonyMethod finalizer) Line 116	C#
ClassLibrary1.dll!ClassLibrary1.Patch.Do() Line 24	C#
ConsoleApp1.dll!Program.<Main>$(string[] args) Line 6	C#

@pardeike pardeike added the bug label Mar 2, 2024
@nike4613
Copy link

nike4613 commented Mar 2, 2024

That looks like a legacy stacktrace, and that supports neither .NET 7 nor .NET 8.

MonoMod.Common

@pardeike
Copy link
Owner

pardeike commented Mar 2, 2024

Here is a more simpler example:

using HarmonyLib;

namespace TestingNet8
{
	internal class Program
	{
		static void Main(string[] args)
		{
			var harmony = new Harmony("test");
			var original = SymbolExtensions.GetMethodInfo(() => new Test().HelloWorld());
			var postfix = SymbolExtensions.GetMethodInfo(() => Patch.Postfix());

			Console.WriteLine("Start");
			harmony.Patch(original, postfix: new HarmonyMethod(postfix));
			Console.WriteLine("Stop");
		}
	}

	public class Test
	{
		public void HelloWorld()
		{
			Console.WriteLine("Hello, World!");
		}
	}

	public class Patch
	{
		public static void Postfix()
		{
			Console.WriteLine("Patched!");
		}
	}
}

In a net7 project it runs Debug+Release. In the same but switched to net8 it has an exception (either Debug or Release)

@pardeike
Copy link
Owner

pardeike commented Mar 2, 2024

image

@pardeike
Copy link
Owner

pardeike commented Mar 2, 2024

That looks like a legacy stacktrace, and that supports neither .NET 7 nor .NET 8.

MonoMod.Common

So how did that come into play with a reference to the nuget package Lib.Harmony 2.3? Lets continue this on the discord.

@pardeike
Copy link
Owner

pardeike commented Mar 2, 2024

Ok, after investigating this I found that my Visual Studio had somehow the wrong (old?) version of Harmony 2.3 in the nuget cache. Not really sure why but after removing all cached versions in C:\Users\Brrainz\.nuget\packages\lib.harmony\... and rebuilding your project, it works as expected. You can verify this before and after cleaning that your dependencies *should not mention MonoMod.Common but only this:

image

After that, your project runs ands debugs fine.

@pardeike pardeike closed this as completed Mar 2, 2024
@Muscipular
Copy link
Author

I tested in vs2022, it work. but in rider was same issue.
I found that MonoMod.Core was loaded in debugger mode.

here is debug output

Loaded application domain 'DefaultDomain (id 1)'
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Private.CoreLib.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Private.CoreLib.dll in application domain 1:DefaultDomain
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Private.CoreLib.dll was not found or failed to read
Started Thread 33880
Loaded Assembly 'C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ConsoleApp1.dll'
Loading module C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ConsoleApp1.dll in application domain 1:clrhost
Symbols for module C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ConsoleApp1.dll loaded
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Console.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Console.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Console.dll was not found or failed to read
Loaded Assembly 'C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ClassLibrary1.dll'
Loading module C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ClassLibrary1.dll in application domain 1:clrhost
Symbols for module C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ClassLibrary1.dll loaded
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.Encoding.Extensions.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.Encoding.Extensions.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.Encoding.Extensions.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.InteropServices.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.InteropServices.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.InteropServices.dll was not found or failed to read
Loaded Assembly 'C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\0Harmony.dll'
Loading module C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\0Harmony.dll in application domain 1:clrhost
Pdb file for assembly C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\0Harmony.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Concurrent.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Concurrent.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Concurrent.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Memory.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Memory.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Memory.dll was not found or failed to read
[2]MonoMod.Core: [MonoMod.Core] Info: Version 1.1.0
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\netstandard.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\netstandard.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\netstandard.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.ILGeneration.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.ILGeneration.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.ILGeneration.dll was not found or failed to read
Loaded Assembly '<unknown>'
Loading module HarmonySharedState in application domain 1:clrhost
Pdb file for assembly  was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\mscorlib.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\mscorlib.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\mscorlib.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.Lightweight.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.Lightweight.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.Lightweight.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Primitives.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Primitives.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Primitives.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.Thread.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.Thread.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.Thread.dll was not found or failed to read
[1]MonoMod.Utils: [MonoMod.Utils] Trace: IsMono: False, IsCoreBcl: True
[1]MonoMod.Utils: [MonoMod.Utils] Trace: Returned system version: 8.0.0
[1]MonoMod.Utils: [MonoMod.Utils] Trace: FrameworkDescription: .NET 8.0.0
[2]MonoMod.Utils: [MonoMod.Utils] Info: Detected runtime: CoreCLR 8.0.0
Loaded Assembly '<unknown>'
Loading module MonoMod.Utils.Cil.ILGeneratorProxy in application domain 1:clrhost
Pdb file for assembly  was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.Expressions.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.Expressions.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.Expressions.dll was not found or failed to read
[1]MonoMod.Utils: [MonoMod.Utils] Trace: new DynamicMethod: System.Void ClassLibrary1.Class1.A_Patch1()
[1]MonoMod.Utils: [MonoMod.Utils] Trace: mdef: System.Void ClassLibrary1.Class1.A_Patch1()
[2]MonoMod.Utils: [MonoMod.Utils] Info: Platform info: Windows x86_64
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.Process.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.Process.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.Process.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.ComponentModel.Primitives.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.ComponentModel.Primitives.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.ComponentModel.Primitives.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.NonGeneric.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.NonGeneric.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.NonGeneric.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\Microsoft.Win32.Primitives.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\Microsoft.Win32.Primitives.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\Microsoft.Win32.Primitives.dll was not found or failed to read
[1]MonoMod.Core: [MonoMod.Core] Trace: Got jit path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\clrjit.dll
Loaded Assembly 'C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\System.Text.Json.dll'
Loading module C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\System.Text.Json.dll in application domain 1:clrhost
Pdb file for assembly C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\System.Text.Json.dll was not found or failed to read
[1]MonoMod.Utils: [MonoMod.Utils] Trace: new DynamicMethod: System.Object MethodHandle_GetLoaderAllocator(System.IntPtr)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: mdef: System.Object MethodHandle_GetLoaderAllocator(System.IntPtr)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: new DynamicMethod: System.Type GetDeclaringTypeOfMethodHandle(System.IntPtr)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: mdef: System.Type GetDeclaringTypeOfMethodHandle(System.IntPtr)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: new DynamicMethod: System.RuntimeMethodInfoStub new RuntimeMethodInfoStub(System.IntPtr,System.Object)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: mdef: System.RuntimeMethodInfoStub new RuntimeMethodInfoStub(System.IntPtr,System.Object)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: new DynamicMethod: System.RuntimeMethodHandle new RuntimeMethodHandle(System.Object)
[1]MonoMod.Utils: [MonoMod.Utils] Trace: mdef: System.RuntimeMethodHandle new RuntimeMethodHandle(System.Object)
[1]MonoMod.Core: [MonoMod.Core] Trace: Allocated ICorJitInfo wrapper vtable at 0x000001f42bdb8a30
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.RegularExpressions.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.RegularExpressions.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.RegularExpressions.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.StackTrace.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.StackTrace.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.StackTrace.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Metadata.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Metadata.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Metadata.dll was not found or failed to read
Loaded Assembly 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Immutable.dll'
Loading module C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Immutable.dll in application domain 1:clrhost
Pdb file for assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Immutable.dll was not found or failed to read

load module:

-- -- -- -- -- -- --
System.Private.CoreLib C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Private.CoreLib.dll [Symbols are not loaded yet] Enabled 1 8.0.0.0 clrhost
ConsoleApp1 C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ConsoleApp1.dll [C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ConsoleApp1.pdb] Enabled 2 1.0.0.0 clrhost
System.Runtime C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.dll [Symbols are not loaded yet] Enabled 3 8.0.0.0 clrhost
System.Console C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Console.dll [Symbols are not loaded yet] Enabled 4 8.0.0.0 clrhost
ClassLibrary1 C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ClassLibrary1.dll [C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\ClassLibrary1.pdb] Enabled 5 1.0.0.0 clrhost
System.Threading C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.dll [Symbols are not loaded yet] Enabled 6 8.0.0.0 clrhost
System.Text.Encoding.Extensions C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.Encoding.Extensions.dll [Symbols are not loaded yet] Enabled 7 8.0.0.0 clrhost
System.Runtime.InteropServices C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Runtime.InteropServices.dll [Symbols are not loaded yet] Enabled 8 8.0.0.0 clrhost
0Harmony C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\0Harmony.dll [Decompiled Symbols] Enabled 9 2.3.0.0 clrhost
System.Collections.Concurrent C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Concurrent.dll [Symbols are not loaded yet] Enabled 10 8.0.0.0 clrhost
System.Memory C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Memory.dll [Symbols are not loaded yet] Enabled 11 8.0.0.0 clrhost
System.Collections C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.dll [Symbols are not loaded yet] Enabled 12 8.0.0.0 clrhost
System.Linq C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.dll [Symbols are not loaded yet] Enabled 13 8.0.0.0 clrhost
netstandard C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\netstandard.dll [Symbols are not loaded yet] Enabled 14 2.1.0.0 clrhost
System.Reflection.Emit.ILGeneration C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.ILGeneration.dll [Symbols are not loaded yet] Enabled 15 8.0.0.0 clrhost
HarmonySharedState   [Symbols are not loaded yet] Enabled 16 0.0.0.0 clrhost
mscorlib C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\mscorlib.dll [Symbols are not loaded yet] Enabled 17 4.0.0.0 clrhost
System.Reflection.Emit.Lightweight C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.Lightweight.dll [Symbols are not loaded yet] Enabled 18 8.0.0.0 clrhost
System.Reflection.Primitives C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Primitives.dll [Symbols are not loaded yet] Enabled 19 8.0.0.0 clrhost
System.Threading.Thread C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Threading.Thread.dll [Symbols are not loaded yet] Enabled 20 8.0.0.0 clrhost
MonoMod.Utils.Cil.ILGeneratorProxy   [Symbols are not loaded yet] Enabled 21 0.0.0.0 clrhost
System.Reflection.Emit C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Emit.dll [Symbols are not loaded yet] Enabled 22 8.0.0.0 clrhost
System.Linq.Expressions C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Linq.Expressions.dll [Symbols are not loaded yet] Enabled 23 8.0.0.0 clrhost
System.Diagnostics.Process C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.Process.dll [Symbols are not loaded yet] Enabled 24 8.0.0.0 clrhost
System.ComponentModel.Primitives C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.ComponentModel.Primitives.dll [Symbols are not loaded yet] Enabled 25 8.0.0.0 clrhost
System.Collections.NonGeneric C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.NonGeneric.dll [Symbols are not loaded yet] Enabled 26 8.0.0.0 clrhost
Microsoft.Win32.Primitives C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\Microsoft.Win32.Primitives.dll [Symbols are not loaded yet] Enabled 27 8.0.0.0 clrhost
System.Text.Json C:\Users\Mayling\RiderProjects\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\System.Text.Json.dll [Symbols are not loaded yet] Enabled 28 8.0.0.0 clrhost
System.Text.RegularExpressions C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Text.RegularExpressions.dll [Symbols are not loaded yet] Enabled 29 8.0.0.0 clrhost
System.Diagnostics.StackTrace C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Diagnostics.StackTrace.dll [Symbols are not loaded yet] Enabled 30 8.0.0.0 clrhost
System.Reflection.Metadata C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Reflection.Metadata.dll [Symbols are not loaded yet] Enabled 31 8.0.0.0 clrhost
System.Collections.Immutable C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Collections.Immutable.dll [Symbols are not loaded yet] Enabled 32 8.0.0.0 clrhost

@pardeike
Copy link
Owner

pardeike commented Mar 2, 2024

We are working on an update to Harmony. We can see if it fixes this issue.

@pardeike pardeike reopened this Mar 2, 2024
@Muscipular
Copy link
Author

I found that , when disable jit optimization on module load was enabled, it will throw that exception.

@pardeike
Copy link
Owner

pardeike commented Mar 3, 2024

This should be fixed with the 2.3.1.1 release I just made

@pardeike pardeike closed this as completed Mar 3, 2024
@Wdestroier
Copy link

I had the same problem on Rider 2023.3 with the new 2.3.1.1 version. The problem didn't happen on Visual Studio 2022. "Supress JIT optimizations on module load (Managed only)" was disabled by default. @zznty suggested on Discord to install Lib.Harmony.Thin instead of Lib.Harmony and it did work.

@AqlaSolutions
Copy link

I have the same issue in Rider with Lib.Harmony 2.3.3

@Muscipular
Copy link
Author

I have the same issue in Rider with Lib.Harmony 2.3.3

Try disable disable jit optimization on module load in rider settings

@AqlaSolutions
Copy link

disable jit optimization on module load is a necessary thing, I need it enabled.

@shiguangwangyu
Copy link

J'ai également eu ce problème lors de l'injection dans un programme Comment devrais - je résoudre le Framework de net7.0 utilisé lors du programme cible j'ai également essayé de désactiver JIT, mais je me trompe quand même

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants