C
C#•12mo ago
Delta 2.1

embding C# for scripting in rust

I'm looking for a way to host C# for scripting, like Unity and godot do. I looked for mono, but I learn that "mono is dead" (since it only support C#7 and we are at C#11) and I should use dotnet now. But mono api for embding was far more complete. How do I expose native function to C#, there is no way to avoid unmanagedCallerOnly on C# callbacks ? How to handle exception (from what i've read, they are only supported on window, any other platfrom will result to an UB)
4 Replies
Jimmacle
Jimmacle•12mo ago
Write a custom .NET runtime host - .NET
Learn to host the .NET runtime from native code to support advanced scenarios that require controlling how the .NET runtime works.
Delta 2.1
Delta 2.1OP•12mo ago
I read this document more than 10 times aka the question on exception
Delta 2.1
Delta 2.1OP•12mo ago
unity and godot seam to handle them with thier dotnet runtime so it must be a way do deal with it 🤔 (mono handle them easly) and for my beloved [MethodImplAttribute(MethodImplOptions.InternalCall)], it exist with hostfxr/coreCLR, but only usable when COM API are defined (using C++/Cli, which isn't cross platfrom) I can pass function pointer and cast them in the C# side, but it get very ugly and unreadable both way, use C# as a scripting language like unity does I'm sorry if I'm a bit dry, it's just that I've been looking at how to implement this for months and months.
Want results from more Discord servers?
Add your server