passing SAFEARRAY from COM to C#

J

Jenny Tam

Hi all,

I'm very new to C#, and I've tried to find an answer to my problems.
We've got a method in an existing COM object as follows:

BOOL CCacheCtrl::IdFromStringRep(LPCTSTR lpszIdStringRep, const
VARIANT FAR& vaResult)
{
ID id;

if ((vaResult.vt == (VT_VARIANT | VT_BYREF)) || (vaResult.vt ==
VT_EMPTY))
{
// reset the SAFEARRAY in vaResult.pvarVal based on
lpszIdStringRep
}

return TRUE;
}

It works with VB no problem. Now we want to try in C#, but we got no
luck. Our code is

===
Byte[] SecondID = new Byte[] {1, 2, 3, 4, 5, 6, 7, 8};
object oid = SecondID;
bool success = myCache.IdFromStringRep(strCompare, oid );
===

Nothing seems wrong, but oid is not changed based on the strCompare
value. So we thought we could add a new method as follows

BOOL CCacheCtrl::IdFromStringRep2(LPCTSTR lpszIdStringRep, VARIANT *
pResult)

In C# we do

===
bool success = myCache.IdFromStringRep2(strCompare, ref oid);
===

However, oid is still unchanged!! What did we do wrong?

Thank you for reading my long post!!
Jenny
 

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