MarshalManagedExceptionMode Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This enum is used to specify what to do when an managed exception is thrown, and that exception reaches native code.
public enum MarshalManagedExceptionMode
type MarshalManagedExceptionMode =
- Inheritance
-
MarshalManagedExceptionMode
Fields
| Name | Value | Description |
|---|---|---|
| Default | 0 | The default mode. This is currently the same as ThrowObjectiveCException. |
| UnwindNativeCode | 1 | Let the runtime unwind native frames. This option is only available when using the MonoVM runtime, not when using CoreCLR runtime. The CoreCLR runtime does not support unwinding native frames, and will just abort the process instead. The CoreCLR runtime is used in a macOS (not Mac Catalyst) app, or when using NativeAOT. This option is not recommended, because it leads to undefined behavior (the app may crash, leak memory, deadlock, etc.) if managed exceptions reaches native code (the MonoVM runtime does not know how to unwind native frames, so anything can happen). The recommended option is ThrowObjectiveCException. |
| ThrowObjectiveCException | 2 | Convert the managed exception to an Objective-C exception. This is the recommended option (and also the default behavior). |
| Abort | 3 | Abort when a managed exception reaches native code. This may be useful during debugging to easily detect when managed exceptions reaches native code. |
| Disable | 4 | Disable marshalling managed exceptions. This is effectively the same as UnwindNativeCode, except that no events will be raised. |