I’ve written a small library in C#.
In this library there are two classes that are ComVisible.
The first one has a method that provide a array of custom objects (declared in the second class).
I tested the library with a small c# application and everything work.
Then I do the same thing VB6. The problem occurs when I call the method I descibed before. I get a Type Mismatch error.
Here’s the BV6 code:
Private Sub Command1_Click()
Dim Flussi As FMDriver.FMDriver
Set Flussi = New FMDriver.FMDriver
[...]
Dim temp() As FMDriver.FM
temp = Flussi.GetElabData(station, codpar, data, tabella, nfunz, tiponfunz)
[...]
This is the custom class FM
[ComVisible(true)]
public partial class FM
{
public FM() { }
[ComVisible(true)]
public double Value { get; set; }
[ComVisible(true)]
public double IDisp { get; set; }
}
Any idea? If from the response I extract only one element it works.
EDIT:
Another strange thing…
Dim pippo As FM
Set pippo = CreateObject("fmdriver.fm")
pippo.Value = 100
pippo.IDisp = 43
pippo = Flussi.GetElabData( [..cut..] )(4)
In Pippo.Value there’s the correct value that GetElabData return on the 4th position of the array but in Pippo.IDisp the value doesn’t change, it remains 43instead of getting the new value.
In the end I created all my beautifull methods that returns custom obj (for .NET apps) and a couple of methods, dedicated to VB6, with the
[ComVisible(true)]tag, that returns more siple arrays of values (part of the result of the other methods).So I think that returning custom Obj to VB6 it’s not very reliable and sometimes it doesn’t work at all.