Trouble compiling C# project with AOT on Windows — GodotPlugins initialization error

Godot Version

4.6 mono

Question

Hi everyone,
I’m trying to compile my C# Godot project into machine code using the Ahead‑of‑Time (AOT) option, but the build fails with the following errors:

ERROR: .NET: Failed to get GodotPlugins initialization function pointer
   at: (modules/mono/mono_gd/gd_mono.cpp:484)
ERROR: Parameter "godot_plugins_initialize" is null.
   at: initialize (modules/mono/mono_gd/gd_mono.cpp:653)

My target platform is Windows.

Has anyone encountered this issue or knows what might be causing it? Any help would be greatly appreciated.

I know code can be obfuscated but I want the binary code.

My guess is that, since AOT has really aggressive trimming, it’s likely trimming the hooks that the C++ side is trying to find, thus leading to failure. Unfortunately I have no experience on how this should be done, but my best guess is that you need to prevent AOT from removing those parts of the binary that it thinks are unnecessary.

Also afaik there’s no one click solution to using AOT yet, you need to do some modifications yourself to make it work.

1 Like