Fastest way to access VB6 String in C#
- by Simon Woods
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