[Mono-dev] Method attributes in Full-AOT code

Jonathan Pryor jonpryor at vt.edu
Fri May 13 10:31:46 EDT 2011

On May 13, 2011, at 3:49 AM, Martin Däumler wrote:
> I learned that PInvoke and Internal Call methods are
> quite the same.

Not quite the same. P/Invoke marshals arguments, internal calls do not.

For a glaring difference between these, consider System.String arguments. With P/Invoke, they become `char*` or `unsigned short*` values (depending on whether it's UTF-8 or UTF-16 marshaling), and may involve copying the data (for UTF-8 conversion). With Internal calls, the native code gets a MonoString*, no marshaling at all.

Internal calls can also get any managed type passed to them (e.g. System.Object); they just become a MonoObject* in native code. Not all types can be used with P/Invoke (e.g. System.Object can't be used in P/Invoke).

 - Jon

More information about the Mono-devel-list mailing list