KeraLua icon indicating copy to clipboard operation
KeraLua copied to clipboard

.NET 9 support

Open 1xKvSUbAg1xJx9KutZW1lzrdGImI3CaW opened this issue 2 months ago • 3 comments

Hello, I was experimenting with your library and noticed yielding does not seem to work on .NET 9, it seems to work on .NET 8 though. Are there any plans for supporting .NET 9? On .NET 9 its throwing runtime exceptions so I assume its something microsoft changed with delegates.

The code I used for my test is

static void Main(string[] args)
{
    var l = new Lua();
    l.Register("yieldTest", TestFunc);
    var c = l.NewThread();

    if(c.LoadString("print('hello world!!');yieldTest();print('after yield!!');") != LuaStatus.OK)
        Console.WriteLine(c.ToString(-1));
    else Console.WriteLine("successfully loadedstring");

    Console.WriteLine(c.Resume(c, 0));
    Console.ReadKey();
    c.Resume(c, 0);
}

static int TestFunc(IntPtr ptr)
{
    var L = Lua.FromIntPtr(ptr);
    Console.WriteLine("emitting a yield");
    return L.Yield(0);
}

Nothing was changed on the Lua/KeraLua side. I am not sure if this was a change in the .NET runtime that broke it. What happens? it crashes ?

viniciusjarina avatar Nov 07 '25 20:11 viniciusjarina

After doing some research the issue seems to be CET now being forced on by default > .net 9

Does <CetCompat>false</CetCompat> help?

MRIIOT avatar Nov 26 '25 18:11 MRIIOT