Also keep in mind that managed-unmanaged interop is quite expensive.
When you call the C++ code a lot it's best when you do that from
unmanaged code.
Also the C++/CLR interop is way faster than the C# interop.
Regards,
Dirk
> Also the C++/CLR interop is way faster than the C# interop.
Hmmm "way faster " Any figures that prove that claim?
No managed code can directly call into unmanaged code, be it MC++ or C#, the
first time you call a native function the CLR creates a stub for the
function to be called (amongst many other things), this stub is the same
whether you call from C# or C++/CLI (the CLR known nothing about these high
level languages), once the stub is in place the same stub will be reused for
the next calls of the (same) function.
Only difference between C# and managed C++ calling into native code is the
security check performed for PInvoke interop, this security check can be
skipped by applying the [SuppressUnmanagedCodeSecurity] attribute. With
this attribute applied the call overhead is the same for all
managed/unmanaged code transitions. Only advantage of Managed C++/ native
C++ interop over PInvoke interop is the level of control when marshalling
arguments from managed to native, but in general this advantage is rather
small.
Willy.