Matriz de objeto personalizado de .NET a VB6
Frecuentes
Visto 1,077 veces
0
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 43
instead of getting the new value.
1 Respuestas
0
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.
respondido 29 nov., 12:10
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# .net vb6 com-interop or haz tu propia pregunta.
this is a complete sample that shows how to solve your problem
http://www.codeproject.com/Articles/12300/An-ASP-NET-Application-Using-a-MySQL-Database
i hope it could help you - HassanationSi
Dim temp() As Object
orDim temp As Variant
, would that get around the Type Mismatch? - rskarHassan Wasef, maybe you post on the wrong question? :) Rskar, if I use Object or Variant I get the same error. :( - Pomp
Whats the definition and code behind
FMDriver.GetElabData()
? - Deanna[ComVisible(true)] public FM[] GetFMData( [...cut...] ) { List<FM> _Result = new List<FM>(); // [... bla bla bla ...] return _Result.ToArray<FM>() }
- Pomp