-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Loading external DLL at runtime errors #75160
Comments
|
This is unrelated to the linked issue, which is about loading native libraries in 3.x This issue is caused using a library that uses Notably when exporting the project, GodotSharp can be found and a second instance will be loaded, but because this is a new instance it does not have to hooks into the engine loaded and thus the exported project crashes with an AV when the loaded library tries to use any native function, (GD.Print here) |
I'm running into this issue as well on 4.1 From my understanding this would mean that "Live Updating" C# code is effectively broken (as it'll likely reference GodotSharp) Is there any workaround to this? |
Still very much sadly present in v4.3.dev2.mono.official [3524346]. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Still present in v4.3.dev5.mono.official [89f70e9]. |
As explained by @RedworkDE in #75160 (comment) you have to make sure to use the same isolated Here's an example, I modified the public partial class ModLoader : Node
{
public override void _Ready()
{
string modPath = ProjectSettings.GlobalizePath("user://TestMod.dll");
var alc = AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly());
Assembly assembly = alc.LoadFromAssemblyPath(modPath);
Type t = assembly.GetType("TestMod.TestModInit");
t.GetMethod("Init")?.Invoke(null, null);
}
} |
Godot version
v4.0.stable.mono.official [92bee43]
System information
Arch Linux
Issue description
When i try to load an external dll from the user data folder (via System.Reflection.Assembly.LoadFile) and invoke a static method it gives this error:
I expect it to load the dll and run the method.
Steps to reproduce
Minimal reproduction project
ModLoader.zip
TestMod.zip
The text was updated successfully, but these errors were encountered: