I am using COM Interop. I have a call in VB6 that returns a string of approximately 13,000 characters. If I make a call in pure VB6, it takes about 800 ms to complete. If I execute it through C # and COM Interop, it will take about 8 seconds. I assume the delay is due to marshaling.
If I am right about marshaling, I would appreciate if anyone could suggest the fastest way to get this in C #. for example It would be better a) expose it as an array of bytes b) provide the byref string parameter to the VB6 level
I would appreciate a sample code. I tried
Marshal.PtrToStringAuto(Marshal.ReadIntPtr(myCOMObject.GetString, 0)
to no avail.
-
Further from Franky's comment. I just reference the VB6 dll (so in the process) from C # dll. Here is an excerpt from OLEView
interface _MyCOMObect : IDispatch { ... [id(0x60030006)] HRESULT GetString( [in] _IEventHistory* p_oEventHistory, [out, retval] _IXML** ); ... }; [ uuid(09A06762-5322-4DC1-90DD-321D4EFC9C3E), version(1.0), custom({17093CC6-9BD2-11CF-AA4F-304BF89C0001}, "0") ] coclass MyCOMObject { [default] interface _CFactory; }; [ odl, uuid(C6E7413F-C63A-43E4-8B67-6AEAD132F5E5), version(1.0), hidden, dual, nonextensible, oleautomation ]
I should probably indicate that the parameter (p_oEventHistory) is another COM object that I create in C #, but it takes about 80 ms
S
string c # vb6 marshalling com-interop
Simon woods
source share