Getting exception 0x80020008 -"Bad variable type.".

  • Thread starter Thread starter snabhi
  • Start date Start date
S

snabhi

Guest
Hello,

I'm invoking a method in C# using InvokeHelper() from C++ code as below.

VARIANT Caller()
{
VARIANT result;
InvokeHelper(<some dispid>, DISPATCH_METHOD, VT_VARIANT, (void*)&result, NULL);
return result;
}

This would call the C# function which looks like

public object Callee()
{
int a= 0;
int b= 0;

//....
//....someother code to assign a and b.
//.......

int[] res= new int[] { a, b};
return res;
}

The return type is 'object' since we want to return a generic type and it is our requirement.

The result returned from caller() is assigned to _variant_t variable during which I'm getting exception 0x80020008 -"Bad variable type.".( the exact function which is throwing exception is ::VariantCopy() which is called during assignment to _variant_t variable ).

Kindly let me know what could be the root cause?

Is my InvokeHelper() function call is correct?Do I need to use VT_ARRAY instead of VT_VARIANT or both in InvokeHelper()?

Continue reading...
 
Back
Top