Is there anyway to target an older version of .NET (Kinect requires .NET Framework)

Godot Version

4.2.1 stable on Windows 10

A Question

I’ve recently gotten my hands on a used Kinect for Xbox One and wanted to see if I could get it to work with Godot. I tried using the NuGet package and building, but got the following error:

E 0:00:03:0043   --- End of inner exception stack trace ---:     . Reference assemblies cannot be loaded for execution. (0x80131058) ---> System.BadImageFormatException: Cannot load a reference assembly for execution.
  <C++ Error>    System.BadImageFormatException
  <C++ Source>   :0 @ --- End of inner exception stack trace ---()
  <Stack Trace>  :0 @ --- End of inner exception stack trace ---()
                 :0 @ void track_body_part._Process(double)
                 Node.cs:2111 @ bool Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name&, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
                 track_body_part_ScriptMethods.generated.cs:48 @ bool track_body_part.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*)

Presumably, Godot either can’t find the required assemblies or won’t load them. I also tried adding the assembly manually, but that didn’t seem to change anything. I tried changing the dotnet version to .NET Framework 4.8 which is supported by the Kinect package, but then Godot SDK was yelling at me…

Is there anyway to get .NET Framework to play nice with Godot 4? If so, please let me know :smiley:
Thanks,
Logan .B

Of course, someone is more than welcome to correct me, but as far as I know, Godot’s mono version uses .NET, and not the .NET Framework (they are different, Microsoft is just really bad at naming things). So if this library only works with .NET Framework, it might not work with .NET at all

Is there perhaps an older version of Godot that doesn’t need .NET Core? (I’m going to use .NET Core to avoid confusing .NET with .NET Framework)

I’m a little confused. Are you using the default version of Godot or the Mono version? Since if you use the Mono version, that obviously needs to use .NET to use C#, and even the older versions will use .NET and not the .NET Framework, but if you use the normal version with GDScript, I’m not entirely sure how to get such a library working at all there. Would you mind linking me the Kinect SDK? Or the DLL you’re trying to include.

Godot 4.X uses .NET (Core)
Godot 3.X uses Mono/.NET Framework, the 4.8 version you are looking for should work there.

For Godot 4 the “Mono” version is just named badly, as it entirely uses the .NET SDK instead of Mono.

Are you using the default version of Godot or the Mono version?

Mono.

Would you mind linking me the Kinect SDK? Or the DLL you’re trying to include.

I hope this works, I don’t know if I can provide the DLL directly…

Godot 3.X uses Mono/.NET Framework, the 4.8 version you are looking for should work there.

I tried (both with the NuGet package and the direct assembly) but I’m now getting this error:

E 0:00:00.954   _real_load_assembly_from: Failed to load assembly for image
  <C++ Error>   Condition "status != MONO_IMAGE_OK || !assembly" is true. Returned: nullptr
  <C++ Source>  modules/mono/mono_gd/gd_mono_assembly.cpp:301 @ _real_load_assembly_from()