using KiDev.IlAsm.FuncPtr;using Microsoft.FSharp.Core;using System.Runtime.InteropServices;unsafe{ delegate* unmanaged<int> x = &Test; Console.WriteLine($"delegate* = {x()}"); // fine var ptr = new FuncPtr<Unit, int>((nint)x); Console.WriteLine($"FuncPtr = {ptr.Call(null!)}"); // exception}[UnmanagedCallersOnly]static int Test() => 12;
using KiDev.IlAsm.FuncPtr;using Microsoft.FSharp.Core;using System.Runtime.InteropServices;unsafe{ delegate* unmanaged<int> x = &Test; Console.WriteLine($"delegate* = {x()}"); // fine var ptr = new FuncPtr<Unit, int>((nint)x); Console.WriteLine($"FuncPtr = {ptr.Call(null!)}"); // exception}[UnmanagedCallersOnly]static int Test() => 12;
I get
System.BadImageFormatException: "Bad element type in SizeOf."
System.BadImageFormatException: "Bad element type in SizeOf."