[Mono-devel-list] Custom Marshalling

Jonathan S. Chambers Jonathan.Chambers at ansys.com
Mon Jul 18 14:16:54 EDT 2005


	I'm following the methods demonstrated in the book '.Net and COM' by Adam Nathan in his chapters on PInvoke and Custom Marshalling. His examples demonstrate marshalling by-ref/out parameters. Plus, (I know this means little), it does work in .Net.
	I'll try to distill the test code to a small sample and post it.

- Jonathan

-----Original Message-----
From: Kornél Pál [mailto:kornelpal at hotmail.com] 
Sent: Monday, July 18, 2005 2:06 PM
To: Jonathan S. Chambers; mono-devel-list at lists.ximian.com
Subject: Re: [Mono-devel-list] Custom Marshalling

According to my experiences by-ref (out is by-ref as well) custom marshaling
is not supported in either runtime. Could you attach please a full test code
(managed and umnanaged source code) to can I try it?

Kornél

----- Original Message -----
From: Jonathan S. Chambers


Hello All,
I am trying to use a custom marshaler in mono. The marshaling
from managed to native is working great, but my custom marshalling code
is not getting hit for the native to managed case. Here are my pinvoke
signatures:

[DllImport(@"TestLib.dll", CallingConvention = CallingConvention.Cdecl)]
public extern static int
SetName([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef =
typeof(StringMarshaler))]string name);

[DllImport(@"TestLib.dll", CallingConvention = CallingConvention.Cdecl)]
public extern static int
GetName([MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(S
tringMarshaler)), Out]out string name);

So my SetName function works fine, but when I call GetName the
MarshalNativeToManaged method on my custom marshaller is not getting
called (and it does in .Net). Any thoughts?

Thanks,
Jonathan

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list





More information about the Mono-devel-list mailing list