Hi everyone.
I made two tests to try to understand what is going on.
First, I added a watch in VB6 to inspect the result of the method call. The result was:
Expression: manager.SearchProducts
Value: <Type mismatch>
Type: Integer
Then I changed the method. Instead of returning an array of Product objetcs the method only returns one object, but now I get a different error :OBJECT DOESNT SUPPORT THIS PROPERTY OR METHOD.
I call the method from vb6 like this:
(Namespace is not theactual namespace, just a placeholder)
Dim prod As Namespace.Product
Set prod =Namespace.Product
prod = manager.SearchProducts 'ERROR: Object doesnt support this propertyor method
I attached the visual studio debugger to VB6.exe and I can see that the code reaches the final return statement in the .NET assembly so it must be something when the control returns to vb6, vb6 is not able to marshal the object.
I also tried using a variant variable but I get the same error.
However, and this really confuses me, If I call the method without assigning the result to a variable the program runs with any errors:
Dim prod As Namespace.Product
Set prod =Namespace.Product
manager.SearchProducts 'No error, code execution continues
Moreover, if I add a watch on the expressionmanager.SearchProducts I can see the results on the watch window in VB6.
The results's type is Object/Product (remeber that the method returns only 1 object of type Product). All the properties are right, all the values are correct, I just can't assign the result to a variable in VB6!!!!!
And please take into account that I have used the Product class before as an input parameter of a method in the .NET assmebly. So, the problems appear when the data is passed from .NET to VB6 not the opposite. Also, the Product class contains only simple data, strings and one double field, no complex data, no arrays.
Any help about how to resolve this issue would be appreciated a lot,
Thanks in advance