Open
Description
Today, the SafeHandle marshaler prohibits null SafeHandle instances:
runtime/src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs
Lines 1251 to 1256 in e489111
but there are native methods that let you pass a null pointer to mean "I don't have one". To call such methods, you then either need to use an IntPtr directly or have multiple P/Invoke definitions (one for when you have a non-null SafeHandle and one for when you have null) or create a throw-away safe handle instance that contains IntPtr.Zero. It's not clear to me why the marshaler prohibits null; it could just marshal it as null / zero.
Metadata
Metadata
Assignees
Type
Projects
Status
No status