-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Harmony fails to patch method and throws exception in exported Godot build #572
Comments
A TypeLoadException means that not all dependencies were available at runtime. Did you use the fat or the thin version of the prerelease? |
I was using the NuGet package, but I just tried both the fat and thin prereleases and got the same result for both (same harmony debug log and exception stacktrace) |
Have you tried to build from master and make a local nuget package by using the pack command on the Harmony project? |
I just attempted all 4 configurations. I was unable to pack ReleaseFat due to the following error:
DebugFat, DebugThin, and ReleaseThin didn't have this issue, but all three of them gave me the same error in the Godot editor:
Same error in exported Godot build too. I noticed in the Harmony log that env/clr had changed to 8.0.2. (Godot uses .Net 6.0) Maybe that is what's causing the error, I'm not sure if I did something wrong when packing it
I then tried to directly use the dlls within the /net6.0 folder of all four configurations and they all behaved just like before - works correctly in the editor, but has the same TypeLoadException in an exported build. |
Not sure what your build environment looks like but Harmony builds and tests fine both in Azure and with GitHub actions today. |
Yeah IDK, just running the latest version of Visual Studio 2022 on Windows 10. I keep getting that error every time I try to build ReleaseFat. Here's the build output log if that helps:
|
This looks like a dependency problem. Without more information, I can't help you and need to close this issue. |
Here's as much more information as I can give: Using Harmony 32e3f7b With the following dlls, as included within the /ReleaseFat/net6.0/ folder All I can gather from the exception stacktrace is that the problem is related to MonoMod.Utils, but all of its dependencies (Mono.Cecil, MonoMod.Backports, and MonoMod.ILHelpers (none of which seem to have any further dependencies)) appear to be present. If there's any more info you think could help fix this, please let me know. |
When I talked about dependencies I meant the system libraries. If BindingFlags is not available then the problem is more on a general .NET version level. |
Turns out that while the exported godot buld uses .Net 6.0.27, the editor itself uses .Net 8.0.2! Thanks for helping to identify that. So I guess one of the dependencies within the /net6.0/ folder isn't actually compatible with .Net 6? I'll see if I can look into this further. |
I did some more tests: test.sh Results
HarmonyExportIssueBuild with DebugFat/DebugThin
HarmonyExportIssueBuild with ReleaseFat
HarmonyExportIssueBuild with ReleaseThin
The patch fails with all four configurations, but ReleaseFat is throwing |
This appears to be a known issue with Godot and external .dll files. godotengine/godot#75160 It's possible to work around this by using reflection as described in this answer: godotengine/godot#75160 (comment)
Do note that at runtime you will need to get the dll file using
instead |
Describe the bug
In an exported Godot build, when attempting to patch a method with a prefix, postfix, or finalizer method, Harmony fails to patch the method and throws an exception.
To Reproduce
Use the following code with Harmony 2.3-prerelease.7 in Godot 4.2.1:
Expected behavior
For the console to print:
Instead, it only prints this (after the exception):
Harmony debug log:
Exception StackTrace:
Runtime environment (please complete the following information):
Additional context
This problem only occurs in exported builds, whether in debug mode or release mode. Code runs as expected within the editor.
The issue may be related to mismatched dependencies as discussed in #562 , but I am unable to identify which dependency is mismatched.
The text was updated successfully, but these errors were encountered: