Closed yangboyd closed 7 months ago
More information please
The code hang at line: type.GetCustomAttributes(true).
HarmonyLib.HarmonyMethodExtensions
///
Do you have a stacktrace? What .NET version? What Harmony version? What operating system? On what hardware? Is this for a game or a web server container? When do you start the patch operation? Could it be that the class that contains the method you want to patch has a static initializer that runs when you patch the method but that is not suppose to run so early?
Answer to all questions are required or else I can’t help
More info: Harmony 2.1.0. .Net 4.3 Windows 10. X86_64 web server. Use Extreme Injector v3 , follow this sample https://github.com/AmmarHourani/Simple-Harmony-2.
The target function is in a dll. Succeed bypassing this error by manual load and manual patch. The patch seems OK, but not triggered. The call stack in dnSpy is like this:
It looks like the target method is called in unnormal way. Fail to get the original method. How to locate the original method? Can this kind of method be hooked?
There are few possible reasons why your patch isn’t called: 1) the original method is too short and is inclined at runtime 2) due to this being a webserver things that normally work can be quite restricted due to security reasons 3) you are using an outdated Harmony version
The call stack is the way how the original method is called. It's called via reflection. Our hook is implemented via reflection too? Maybe they conflicted.
Calling methods via reflection does not prevent patches to run.
Fixed, It's the app domain isolation, need inject to the specific app domain.
Yeah, see my second guess. Nice
Hook fail, No log file generated.