444surf
444surf
CC#
Created by 444surf on 6/1/2024 in #help
MarshalDirectiveException: Cannot marshal 'return value': Invalid managed/unmanaged type combination
Basically trying to wrap a dll (wiiuse library) into my godot game with c# and whenever i call my wrapped function i get this error:
E 0:00:00:0903 System.IntPtr[] WiiUse.WiiuseInit(int): System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'return value': Invalid managed/unmanaged type combination.
<C++ Error> System.Runtime.InteropServices.MarshalDirectiveException
<C++ Source> :0 @ System.IntPtr[] WiiUse.WiiuseInit(int)
<Stack Trace> :0 @ System.IntPtr[] WiiUse.WiiuseInit(int)
Test.cs:12 @ void Test._Ready()
Node.cs:2137 @ bool Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name&, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
Test_ScriptMethods.generated.cs:48 @ bool Test.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*)
E 0:00:00:0903 System.IntPtr[] WiiUse.WiiuseInit(int): System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'return value': Invalid managed/unmanaged type combination.
<C++ Error> System.Runtime.InteropServices.MarshalDirectiveException
<C++ Source> :0 @ System.IntPtr[] WiiUse.WiiuseInit(int)
<Stack Trace> :0 @ System.IntPtr[] WiiUse.WiiuseInit(int)
Test.cs:12 @ void Test._Ready()
Node.cs:2137 @ bool Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name&, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
Test_ScriptMethods.generated.cs:48 @ bool Test.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*)
My Code:
[DllImport("wiiuse.dll", EntryPoint = "wiiuse_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr[] WiiuseInit(int numWiimotes);
[DllImport("wiiuse.dll", EntryPoint = "wiiuse_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr[] WiiuseInit(int numWiimotes);
3 replies