471,056 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,056 software developers and data experts.

Best COM to managed marshaler

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
Aug 29 '06 #1
1 802
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

"Bob" <ms****@hotmail.comwrote in message
news:e1*************@TK2MSFTNGP03.phx.gbl...
>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

Aug 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

42 posts views Thread by Irmen de Jong | last post: by
20 posts views Thread by Joe | last post: by
3 posts views Thread by vijay.gandhi | last post: by
7 posts views Thread by Ashutosh Bhawasinka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.