Closed
Description
#94615 added EntryPoint support to UCO on wasm (it was missing before)
[UnmanagedCallersOnly(EntryPoint = "display_meaning")]
public static void DisplayMeaningExport(int meaning)
{
Console.WriteLine($"The meaning of life is {meaning}");
}
but there is currently an issue with when invoking the export from unmanaged when there is no managed delegate pointing to it and something akin to the following workaround is required:
Intptr workaround = (IntPtr)(delegate* unmanaged<int,void>)&display_meaning; // needs to be in method loaded by interp prior to unmanaged call
This is because get_native_to_interp
must be called before attempting to invoke the unmanaged entry point or the call will fail. Without the call wasm_native_to_interp_ftndescs
is never initialized. For the workaround to work the delegate * does not need to be reached/reachable, the interpreter simply needs to resolve the method prior to calling it from unmanaged.