Building on anthony-arnold's comment, it could be that the C++ side tries to pass NULL to the structure parameters (I've had similar issues with native code). Make the structure params IntPtr instead (without the ref keyword) and check if they are zero. If they're not zero you can get a struct out of them like so:
private static void Handler(IntPtr structPointer)
{
if (structPointer == IntPtr.Zero)
{
// struct is NULL (0)
}
else // valid struct
{
MyStruct structure;
structure = System.Runtime.InteropServices.Marshal.PtrToStructure(
structPointer,
typeof(MyStruct));
// do work with structure
}
}
I don't think it should be needed for the uint
parameters as passing NULL from the C++ side should set them to 0(?) (I'm not sure on this, someone correct me if I'm wrong).