Interop: marshaling double pointers that can be null

I recently had to implement IMediaBuffer in managed code. The GetBufferAndLength method takes a BYTE** ppBuffer argument, so I initially went with the following straightforward C# declaration:  public void GetBufferAndLength(out IntPtr ppBuffer, out uint cbLength) { ppBuffer = myBuffer;…} This seemed to work fine, until I noticed a lot of first time NullReferenceExceptions were scrolling by…

0