Comments (13)
A TypeLoadException means that not all dependencies were available at runtime. Did you use the fat or the thin version of the prerelease?
from harmony.
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)
from harmony.
Have you tried to build from master and make a local nuget package by using the pack command on the Harmony project?
from harmony.
I just attempted all 4 configurations. I was unable to pack ReleaseFat due to the following error:
C:\Harmony-master\ILRepack.targets(7,3): error : Failed to resolve System.Reflection.BindingFlags
DebugFat, DebugThin, and ReleaseThin didn't have this issue, but all three of them gave me the same error in the Godot editor:
E 0:00:01:0384 void Main._Ready(): System.TypeInitializationException: The type initializer for 'HarmonyLib.HarmonySharedState' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'. The system cannot find the file specified.
File name: 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'
at HarmonyLib.HarmonySharedState.GetOrCreateSharedStateType()
at HarmonyLib.HarmonySharedState..cctor()
--- End of inner exception stack trace ---
at HarmonyLib.HarmonySharedState.GetPatchInfo(MethodBase method)
at HarmonyLib.PatchProcessor.Patch()
at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
at Main._Ready() in C:\Godot Projects\HarmonyExportIssue\Main.cs:line 24
<C# Source> Main.cs:24 @ void Main._Ready()
<Stack Trace> GD.cs:382 @ void Godot.GD.PushError(System.Object[])
Main.cs:24 @ void Main._Ready()
Node.cs:2117 @ bool Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name&, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
Main_ScriptMethods.generated.cs:58 @ bool Main.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name&, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
CSharpInstanceBridge.cs:24 @ Godot.NativeInterop.godot_bool Godot.Bridge.CSharpInstanceBridge.Call(nint, Godot.NativeInterop.godot_string_name*, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant_call_error*, Godot.NativeInterop.godot_variant*)
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
### Harmony id=com.rumbler.patch, version=2.3.0.0, location=, env/clr=8.0.2, platform=Win32NT
### Started from virtual System.Void Main::_Ready(), location
### At 2024-02-16 12.22.15
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.
from harmony.
Not sure what your build environment looks like but Harmony builds and tests fine both in Azure and with GitHub actions today.
from harmony.
See https://github.com/pardeike/Harmony/actions/runs/7906164818
from harmony.
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:
Build started at 05:58...
Restored C:\Harmony-master\TestLibrary\TestLibrary.csproj (in 55 ms).
Restored C:\Harmony-master\Harmony\Documentation\Documentation.csproj (in 94 ms).
Restored C:\Harmony-master\Harmony\Harmony.csproj (in 118 ms).
Restored C:\Harmony-master\HarmonyTests\HarmonyTests.csproj (in 579 ms).
1>------ Build started: Project: Harmony, Configuration: ReleaseFat Any CPU ------
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\netstandard2.0\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\netstandard2.0\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\MonoMod.Utils.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\System.Reflection.Emit.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\System.Reflection.Emit.ILGeneration.dll'
1>Added assembly 'bin\ReleaseFat\netstandard2.0\System.Reflection.Emit.Lightweight.dll'
1>Merging 13 assembies to 'bin\ReleaseFat\netstandard2.0\\0Harmony.dll'
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net472\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net472\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net472\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net472\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net472\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net472\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net472\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net472\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net472\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net472\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net472\MonoMod.Utils.dll'
1>Added assembly 'bin\ReleaseFat\net472\System.ValueTuple.dll'
1>Merging 11 assembies to 'bin\ReleaseFat\net472\\0Harmony.dll'
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net452\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net452\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net452\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net452\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net452\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net452\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net452\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net452\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net452\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net452\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net452\MonoMod.Utils.dll'
1>Added assembly 'bin\ReleaseFat\net452\System.ValueTuple.dll'
1>Merging 11 assembies to 'bin\ReleaseFat\net452\\0Harmony.dll'
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net35\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net35\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net35\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net35\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net35\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net35\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net35\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net35\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net35\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net35\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net35\MonoMod.Utils.dll'
1>Merging 10 assembies to 'bin\ReleaseFat\net35\\0Harmony.dll'
1>Merge succeeded in 1.4776917 s
1>Merge succeeded in 2.3744514 s
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net48\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net48\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net48\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net48\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net48\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net48\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net48\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net48\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net48\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net48\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net48\MonoMod.Utils.dll'
1>Added assembly 'bin\ReleaseFat\net48\System.ValueTuple.dll'
1>Merging 11 assembies to 'bin\ReleaseFat\net48\\0Harmony.dll'
1>Merge succeeded in 2.460817 s
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\netcoreapp3.0\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.0\MonoMod.Utils.dll'
1>Merging 10 assembies to 'bin\ReleaseFat\netcoreapp3.0\\0Harmony.dll'
1>Merge succeeded in 1.5580721 s
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\netcoreapp3.1\0Harmony.dll
1>Merge succeeded in 4.0784896 s
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\netcoreapp3.1\MonoMod.Utils.dll'
1>Merging 10 assembies to 'bin\ReleaseFat\netcoreapp3.1\\0Harmony.dll'
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net5.0\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net5.0\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\MonoMod.Utils.dll'
1>Added assembly 'bin\ReleaseFat\net5.0\System.Text.Json.dll'
1>Merging 11 assembies to 'bin\ReleaseFat\net5.0\\0Harmony.dll'
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net6.0\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net6.0\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\MonoMod.Utils.dll'
1>Added assembly 'bin\ReleaseFat\net6.0\System.Text.Json.dll'
1>Merging 11 assembies to 'bin\ReleaseFat\net6.0\\0Harmony.dll'
1>Merge succeeded in 3.3704322 s
1>C:\Harmony-master\ILRepack.targets(7,3): error : Failed to resolve System.Reflection.BindingFlags
1>Done building project "Harmony.csproj" -- FAILED.
1>Merge succeeded in 6.2760922 s
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net7.0\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net7.0\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net7.0\MonoMod.Utils.dll'
1>Merging 10 assembies to 'bin\ReleaseFat\net7.0\\0Harmony.dll'
1>Harmony -> C:\Harmony-master\Harmony\bin\ReleaseFat\net8.0\0Harmony.dll
1>Added assembly 'bin\ReleaseFat\net8.0\0Harmony.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\Mono.Cecil.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\Mono.Cecil.Mdb.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\Mono.Cecil.Pdb.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\Mono.Cecil.Rocks.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\MonoMod.Backports.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\MonoMod.Core.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\MonoMod.Iced.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\MonoMod.ILHelpers.dll'
1>Added assembly 'bin\ReleaseFat\net8.0\MonoMod.Utils.dll'
1>Merging 10 assembies to 'bin\ReleaseFat\net8.0\\0Harmony.dll'
1>Merge succeeded in 3.1084627 s
1>Merge succeeded in 7.1624303 s
1>Merge succeeded in 3.4050145 s
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 05:59 and took 17.481 seconds ==========
from harmony.
This looks like a dependency problem. Without more information, I can't help you and need to close this issue.
from harmony.
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
0Harmony.dll
Mono.Cecil.dll (0.11.5)
Mono.Cecil.Mdb.dll (0.11.5)
Mono.Cecil.Pdb.dll (0.11.5)
Mono.Cecil.Rocks.dll (0.11.5)
MonoMod.Backports.dll (1.1.0)
MonoMod.Core.dll (1.1.0)
MonoMod.Iced.dll (1.17.0)
MonoMod.ILHelpers.dll (1.0.1)
MonoMod.Utils.dll (25.0.4)
System.Text.Json.dll (6.0.2523.51912)
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.
from harmony.
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.
from harmony.
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.
from harmony.
I did some more tests:
test.sh Results
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net35\HarmonyTests.dll (.NETFramework,Version=v3.5)
Starting test execution, please wait...
Framework35 is not supported. For projects targeting .Net Framework 3.5, test will run in CLR 4.0 "compatibility mode".
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 10 s - HarmonyTests.dll (net35)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net452\HarmonyTests.dll (.NETFramework,Version=v4.5.2)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 8 s - HarmonyTests.dll (net452)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net472\HarmonyTests.dll (.NETFramework,Version=v4.7.2)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 8 s - HarmonyTests.dll (net472)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net48\HarmonyTests.dll (.NETFramework,Version=v4.8)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 7 s - HarmonyTests.dll (net48)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\netcoreapp3.0\HarmonyTests.dll (.NETCoreApp,Version=v3.0)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 5 s - HarmonyTests.dll (netcoreapp3.0)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\netcoreapp3.1\HarmonyTests.dll (.NETCoreApp,Version=v3.1)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 4 s - HarmonyTests.dll (netcoreapp3.1)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net5.0\HarmonyTests.dll (.NETCoreApp,Version=v5.0)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 4 s - HarmonyTests.dll (net5.0)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net6.0\HarmonyTests.dll (.NETCoreApp,Version=v6.0)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 4 s - HarmonyTests.dll (net6.0)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net7.0\HarmonyTests.dll (.NETCoreApp,Version=v7.0)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 3 s - HarmonyTests.dll (net7.0)
Test run for C:\Harmony-master\HarmonyTests\bin\Debug\net8.0\HarmonyTests.dll (.NETCoreApp,Version=v8.0)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 227, Skipped: 2, Total: 229, Duration: 3 s - HarmonyTests.dll (net8.0)
HarmonyExportIssueBuild with DebugFat/DebugThin
C:\HarmonyExportIssueBuild>HarmonyExportIssue.console.exe
Godot Engine v4.2.1.stable.mono.official.b09f793f5 - https://godotengine.org
Vulkan API 1.2.170 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon (TM) R9 390 Series
System.Environment.Version: 6.0.27
ERROR: System.TypeInitializationException: The type initializer for 'HarmonyLib.HarmonySharedState' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'. The system cannot find the file specified.
File name: 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'
at HarmonyLib.HarmonySharedState.GetOrCreateSharedStateType()
at HarmonyLib.HarmonySharedState..cctor() in C:\Harmony-master\Harmony\Internal\HarmonySharedState.cs:line 47
--- End of inner exception stack trace ---
at HarmonyLib.HarmonySharedState.GetPatchInfo(MethodBase method) in C:\Harmony-master\Harmony\Internal\HarmonySharedState.cs:line 107
at HarmonyLib.PatchProcessor.Patch() in C:\Harmony-master\Harmony\Public\PatchProcessor.cs:line 135
at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer) in C:\Harmony-master\Harmony\Public\Harmony.cs:line 167
at Main._Ready() in C:\Godot Projects\HarmonyExportIssue\Main.cs:line 27
at: void Main._Ready() (C:/Godot Projects/HarmonyExportIssue/Main.cs:27)
MethodToTryPatching
HarmonyExportIssueBuild with ReleaseFat
C:\HarmonyExportIssueBuild>HarmonyExportIssue.console.exe
Godot Engine v4.2.1.stable.mono.official.b09f793f5 - https://godotengine.org
Vulkan API 1.2.170 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon (TM) R9 390 Series
System.Environment.Version: 6.0.27
ERROR: System.ArgumentException: GenericArguments[0], 'MonoMod.Utils.Cil.CecilILGenerator', on 'MonoMod.Utils.Cil.ILGeneratorProxy[TTarget]' violates the constraint of type 'TTarget'.
---> System.TypeLoadException: GenericArguments[0], 'MonoMod.Utils.Cil.CecilILGenerator', on 'MonoMod.Utils.Cil.ILGeneratorProxy[TTarget]' violates the constraint of type parameter 'TTarget'.
at System.RuntimeTypeHandle.Instantiate(RuntimeType inst)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
--- End of inner exception stack trace ---
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at MonoMod.Utils.Cil.ILGeneratorShim.GetProxy()
at MonoMod.Utils.DynamicMethodDefinition.GetILGenerator()
at HarmonyLib.MethodPatcher..ctor(MethodBase original, MethodBase source, List`1 prefixes, List`1 postfixes, List`1 transpilers, List`1 finalizers, Boolean debug)
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)
at Main._Ready() in C:\Godot Projects\HarmonyExportIssue\Main.cs:line 27
at: void Main._Ready() (C:/Godot Projects/HarmonyExportIssue/Main.cs:27)
MethodToTryPatching
HarmonyExportIssueBuild with ReleaseThin
C:\HarmonyExportIssueBuild>HarmonyExportIssue.console.exe
Godot Engine v4.2.1.stable.mono.official.b09f793f5 - https://godotengine.org
Vulkan API 1.2.170 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon (TM) R9 390 Series
System.Environment.Version: 6.0.27
ERROR: System.TypeInitializationException: The type initializer for 'HarmonyLib.HarmonySharedState' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'. The system cannot find the file specified.
File name: 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'
at HarmonyLib.HarmonySharedState.GetOrCreateSharedStateType()
at HarmonyLib.HarmonySharedState..cctor()
--- End of inner exception stack trace ---
at HarmonyLib.HarmonySharedState.GetPatchInfo(MethodBase method)
at HarmonyLib.PatchProcessor.Patch()
at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
at Main._Ready() in C:\Godot Projects\HarmonyExportIssue\Main.cs:line 27
at: void Main._Ready() (C:/Godot Projects/HarmonyExportIssue/Main.cs:27)
MethodToTryPatching
The patch fails with all four configurations, but ReleaseFat is throwing System.TypeLoadException
, whereas the other three are throwing System.IO.FileNotFoundException
from harmony.
I tested with a .Net 6.0 console app and it worked with no issues. I'll close the issue seeing as the problem does not appear to be on Harmony's end.
I'm still thoroughly confused by this problem though.
It seems as though the Godot export uses a different set of system dependencies from the console app. Their filesizes differ, despite them both using .Net 6.0.27 and having the exact same file metadata. I have no idea what the difference between them would be.
If anyone knows what's going on here, please let me know.
from harmony.
Related Issues (20)
- A crash after hook:The object's current state invalidates the operation HOT 2
- NuGet Package reference assembly conflict HOT 8
- ModuleInitializerAttribute HOT 1
- RtDynamicMethod get MetadataToken throws InvalidOperationException HOT 2
- Patch on .net 7&8 throw TypeLoadException while debugging HOT 18
- Harmony 3.0: Utility Epic
- Investigate Testing the NuGet Package Directly HOT 3
- Add a Release Pipeline
- Hook exception: System.Exception: Cannot get result from void method System.Void HOT 2
- How to patch method of base class? HOT 1
- When applying a patch fails, the replacement's IL is not printed to the debug log HOT 2
- System.Exception: Parameter "xx" not found in method HOT 10
- SymbolExtensions does not resolve overriden method HOT 3
- can lib work in arm64? HOT 2
- Companion project promotion: Harmony Tools HOT 3
- PatchFunctions.UpdateWrapper NotImplementedException on MacOS HOT 11
- Harmony.Patch() is a bit slow. HOT 2
- 'CORINFO_METHOD_INFO' from assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. HOT 4
- I try to hook DateTime.UtcNow but it throw exception HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from harmony.