none
How does a type like uint? get marshalled by default to COM Interop? RRS feed

  • Question

  • Would that be a ulong*?  I have a uint out parameter that I need to be able to pass null to.  Any suggestions?

    Will Pittenger

    Wednesday, September 24, 2014 12:22 AM

All replies

  • Hello Will,

    >>How does a type like uint? get marshalled by default to COM Interop?

    As far as I know, type as T? which represents null able could not be recognized by COM Interop. You might need to expose an object type instead as described here:

    http://stackoverflow.com/a/6502206

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 25, 2014 2:44 AM
    Moderator
  • Well, I don't control the native side of things.  So I was thinking of a custom marshaler.  I now have a generic implementation that can do most types where both the native and .NET sides are the same type.  (So the type can be copied byte-by-byte.)  But I don't know if the System.IntPtr I give to or get from .NET should point to a uint or a uint*.

    Will Pittenger

    Thursday, September 25, 2014 5:12 AM
  • Hi,

    >>But I don't know if the System.IntPtr I give to or get from .NET should point to a uint or a uint*.

    Based on the constructors of the System.IntPtr, it should point to uint* as it could accept a void* parameter. There is a thread which discusses about the conversion between the System.IntPtr and unit* which might  be helpful to you:

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/df1388cd-de06-40b4-9008-5066463da2a1/cannot-convert-from-uint-to-systemintptr?forum=clr

    If i misunderstand, please let me know.

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 25, 2014 6:59 AM
    Moderator
  • I meant what COM would see.  The method in the interface takes a uint*.  So I can allocate a simple uint and return a pointer to that—or allocate a uint* and a uint.  In that case, the uint* would be set to point to the uint.  I then return a pointer to the uint* (effectively a uint**).

    Does any of that make sense?


    Will Pittenger

    Thursday, September 25, 2014 6:52 PM