C# Library works in editor but not in build

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

I’ve been trying to use Harmony (GitHub - pardeike/Harmony: A library for patching, replacing and decorating .NET and Mono methods during runtime) with Godot, and strangely it works perfectly within the editor, but it doesn’t work in an exported build.

The issue seems to be related to .Net version incompatibility. Within the Godot Editor, System.Environment.Version is 8.0.2, but in an exported build, the version is 6.0.27.

Despite this, none of the Harmony releases of any version appear to work with an exported Godot build. (More details here: Harmony fails to patch method and throws exception in exported Godot build · Issue #572 · pardeike/Harmony · GitHub)

The one thing I have identified is that the .dll files appear to be slightly different between a .Net 6.0.27 Console App (which works correctly with Harmony), and the exported Godot build. All the metadata seems to be the same, but the filesizes differ.

Does anyone have any idea what’s going on here, or how to fix this problem?

1 Like