[Mono-list] Custom Marshalling

Marcus mathpup@mylinuxisp.com
Thu, 28 Oct 2004 17:26:47 -0500

I'm a little confused by your description. I am not trying to be difficult, 
but you use the pronoun "it" in many places where the antecedent is unclear. 
Also, the phrase "on its way out" is not clear.

Perhaps if you demonstrated the problem using a P/Invoke method with fewer 
parameters and explained any problems with "in", "out", and "ref" parameters 
separately, I could better understand.


On Thursday 28 October 2004 1:12 pm, Neale.Ferguson@SoftwareAG-USA.com wrote:
> I've implemented some custom marshalling for an external call so that the
> parameters being sent gets massaged as required by the external routine. In
> addition, it is supposed to massage data after the call. However, while it
> will do so on the way out, it's not being driven the other way. I found
> that if I specified "ref" on the parameters being passed then the
> MarshalManagedToNative method will not be driven, if I specify nothing or
> "out" then neither the ToNative or ToManaged methods are being called.
>                 [DllImport(libname, EntryPoint = "scumbag")]
>                 private unsafe static extern void scumbag          (ref
> XXXCB cb, [MarshalAs(UnmanagedType.CustomMarshaler,
>                          MarshalTypeRef = typeof (AdaByteBuffer))]
> XXXBuffer fb, [MarshalAs(UnmanagedType.CustomMarshaler,
>                          MarshalTypeRef = typeof (AdaByteBuffer))]
> XXXBuffer rb, [MarshalAs(UnmanagedType.CustomMarshaler,
>                          MarshalTypeRef = typeof (AdaByteBuffer))]
> XXXBuffer sb, [MarshalAs(UnmanagedType.CustomMarshaler,
>                          MarshalTypeRef = typeof (AdaByteBuffer))]
> XXXBuffer vb, [MarshalAs(UnmanagedType.CustomMarshaler,
>                          MarshalTypeRef = typeof (AdaIntBuffer))]  XXXIB
> ib);