Interoperability issue between VC++ (ocx) & VB.NET applications
Hello,
We are migrating a product from VB6 to VB.NET and facing an issue.
This product interacts with a function defined in VC++ component (.ocx).
1. VB6 & VB.NET function call:
result = TestFunc(Param1, Param2, Param3)
2. VC++:
a) Function definition in .CPP file:
long TestFunc(long FAR* Param1, const VARIANT FAR& Param2, long Param3)
{
...
}
b) Function signature in .ODL file:
long TestFunc(long* Param1, VARIANT Param2, long Param3);
c) Function signature in .h(header) file:
afx_msg long TestFunc(long FAR* Param1, const VARIANT FAR& Param2, long Param3);
"Param2" in above "TestFunc" is defined as byte array in VB6 & VB.NET.
In VC++, the corresponding type for "Param2" in "TestFunc" is - "const VARIANT FAR& Param2".
In VB6, the byte array values passed gets modified in VC++ "TestFunc" & the modified values are received in VB6 "Param2" variable.
Issue in VB.NET:
In VB.NET, the byte array values passed gets modified in VC++ "TestFunc".
However, the modified values are not transferred from VC++ to VB.NET. The "Param2" variable still has the original values & not the modified values.
Could you please provide us information on how to obtain the modified byte array values in VB.NET from the Variant variable in VC++ component?
Thanks in advance.
Re: Interoperability issue between VC++ (ocx) & VB.NET applications
The const qualifier in
Code:
long TestFunc(long FAR* Param1, const VARIANT FAR& Param2, long Param3)
must be removed to allow this function to modify the Param2.
Re: Interoperability issue between VC++ (ocx) & VB.NET applications
Good point, Victor, however, if that was the problem, wouldn't then the C++ compiler flag attempts to modify the passed byte array as an error in the first place? Wouldn't const, as it's used here, just make the VARIANT structure itself constant, but not the actual array it refers to? (I'm not completely sure about the latter, though, as I'm currently not aware of the details concerning the VARIANT structure at the time.)
Besides, to me this looks more like a VB .NET question, or perhaps native C++, rather than C++/CLI, so maybe the thread should be moved to the appropriate forum section?
Re: Interoperability issue between VC++ (ocx) & VB.NET applications
Quote:
Originally Posted by
Eri523
Besides, to me this looks more like a VB .NET question, or perhaps native C++, rather than C++/CLI, so maybe the thread should be moved to the appropriate forum section?
Agree. So move it to VC++ forum