// I'm using Stdcall here, but it doesn't seem to matter which calling convention is used
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
public static void Callback()
{
Console.WriteLine("Hello from Callback()!");
try
{
Console.WriteLine("Throwing the exception in Callback()!");
throw new Exception("Exception in Callback()");
}
catch
{
Console.WriteLine("Caught the exception in Callback()!");
}
}
public static unsafe void Main()
{
Console.WriteLine("Starting program!");
delegate* unmanaged[Stdcall]<void> callback = &Callback;
callback();
Console.WriteLine("Ending program!");
}
// I'm using Stdcall here, but it doesn't seem to matter which calling convention is used
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
public static void Callback()
{
Console.WriteLine("Hello from Callback()!");
try
{
Console.WriteLine("Throwing the exception in Callback()!");
throw new Exception("Exception in Callback()");
}
catch
{
Console.WriteLine("Caught the exception in Callback()!");
}
}
public static unsafe void Main()
{
Console.WriteLine("Starting program!");
delegate* unmanaged[Stdcall]<void> callback = &Callback;
callback();
Console.WriteLine("Ending program!");
}