I don't understand why function pointer works this way.
In this code, an error occurs when TestMode = 1 or 2 and no error occurs when TestMode = 3.
I get the same result whether I use Release Build, Debug Build, or Ctrl+F5.
I am using C# 9.

3 Replies
https://pastebin.com/ftJVPDZt
This is source code.
Pastebin
what - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I don't know enough to say exactly why this isn't working, but have you seen anything to indicate that it should work?
I note that the docs for
GetFunctionPointer
say:
For instance method handles, the value is not easily usable from user code and is meant exclusively for usage within the runtime.
The simple answer is it isn't supported for instance methods.
I'm reality the target site for a struct instance method doesn't expect a pointer.