Best COM to managed marshaler

B

Bob

I have a project that uses both managed C# and an unmanaged COM object. I
would like to know the best way to transfer large chunks of data between the
two? I have a continuous stream of BYTE arrays that are on average 4k in
size that I need to move from the COM object to C# as fast and efficient as
possible. I'm thinking either an event that passes in a SafeArray or
using a socket.

Does anyone have any experience with and know what will perform best for me?


Bob
 
M

Marcus Heege

If your C# code does not run with restricted CAS permissions, you can use
the C# compiler option /unsafe, the C# keyword unsafe, and byte* types in
your C# code. Using this, you can pass a native pointer from native code to
managed code. This means that noting needs to be copied. On the C# side, you
can either use C++ like pointer arithmetics to iterate throurgh the native
arrray, or you can use the UnmanagedMemoryStream.

Marcus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top