Marshaling is engaged in any case. In some cases, however, as J.Merrill
pointed out, the marshaling is trivial and does not involve actual data
transformations.

Managed-unmanaged code interactions, be it IJW or "true" P/Invoke always
require marshaling. You can get perf gains from IJW just because you
don't need to load additional DLLs, but that's about it. No perf
difference due to marshaling.

Thanks,
Serge

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of J. Merrill
Sent: Tuesday, November 29, 2005 12:50 PM
To: [email protected]
Subject: Re: [ADVANCED-DOTNET] Difference between PInvoke and IJW

I'd say that it's pretty hard to comment definitively without info about
what unmanaged code is being called, and what C++ data is being passed.
Do you have any samples?  You seem pretty confident that PInvoke is
always slower, when I don't see how that can be true in every case (or
how you could have tested every case).

The marshaling from managed to unmanaged types can only be skipped if
the data being passed is already in a format usable by the unmanaged
code.  For example, C-style (null-terminated) strings (not managed
strings declared with __gc) are in the form that most API calls expect,
so no marshaling is needed there.  But in most other cases, some kind of
marshaling is needed.

At 06:26 PM 11/28/2005, Muhammad Adel wrote
>Hello
>I would like to know what is the cause in performance difference
between the
>PInvoke and the IJW methods. Is the marshaling of data from managed to
>unmanaged types skipped when using the IJW method?
>Thanks in advance.
>
>Muhammad Adel
> <http://mohammadadel.blogspot.com/> My blogs


J. Merrill / Analytical Software Corp

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to