c# aot try-catch not work

Dan Yang 0 Reputation points
2023-09-20T07:45:26.5166667+00:00

I used c# aot to compile lib for go use.

An exception occurs in lib and the process crashes.

I hope the process doesn't crash and that bugs can be reported.

How can I keep the process from crashing.

If it crashes, is there any way to find the location of the crash?

    [UnmanagedCallersOnly(EntryPoint = "NativeTest")]
    public static void NativeTest()
    {
			try 
			{     
				List<int> ints = new List<int>();     
				ints = null;     
				ints[0] = 110; 
			} 
			catch (System.Exception e) 
			{     
				Log.Info(e.ToString()); 
			}
    }
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,858 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.