Fastest way to access VB6 String in C#
Posted
by Simon Woods
on Stack Overflow
See other posts from Stack Overflow
or by Simon Woods
Published on 2010-03-30T06:04:38Z
Indexed on
2010/03/30
6:13 UTC
Read the original article
Hit count: 668
Hi
I am using COMInterop. I have a call in VB6 which returns a string of roughly 13000 chars. If I execute the call in pure VB6 it takes about 800ms to execute. If I execute it via c# and COMInterop it takes about 8 seconds. I'm assuming the delay is caused by marshalling.
If I am correct about marshalling, I'd be grateful if someone could suggest the fastest way I can get this into C#. e.g. Would it be better to a) expose it as a byte array b) provide a byref string param into the VB6 layer
I would appreciate some sample code as well. I tried the
Marshal.PtrToStringAuto(Marshal.ReadIntPtr(myCOMObject.GetString, 0)
to no avail
Many thx
S
© Stack Overflow or respective owner