I have some VB6 code that can't be modified easily that looks like this:
Dim cCount as Long
Dim rCount as Long
Dim result()
Set mx = CreateObject("Component.Class")
Dim rtn = mx.GetList(rCount,cCount,result)
The method it calls is currently a VB6 component that we've migrated to .NET with one issue. We're not sure what type the result() is looking for since it's a variant type. We've tried object, object[], object[][], string, string[], etc, none of which have worked.
Here's an example:
public bool GetList(ref long rCount, ref long cCount, ref object result)
{
...
}
I've even tried setting the third param to VariantWrapper since it will add ByRef as necessary:
public bool GetList(ref long rCount, ref long cCount, VariantWrapper result)
{
...
}
Any ideas what I can set the incoming result to be so that I don't have an unhandled exception?
I've created a test Interface (for COM), test Class, and test VB6 app to ensure it was an issue with the Variant. So, it's defined like so:
.NET Interface:
[DispId(1)]
[ComVisible(true)]
string Test(ref object[] value);
VB 6 method:
Private Sub Command1_Click()
Set mx = CreateObject("Component.Class")
Dim result()
MsgBox mx.Test(result)
End Sub
Same issue as described above. In VB6, it just throws me out. If I compile and run it, I get a generic .NET exception and it throws me out.