How to pass a VB6 array to C# through COM Interop?
I would like to call a method in VB6 that has an array as a parameter. Unfortunately VB complains about the inappropriate type. My C# code:
public void CreateMultipleNewEsnBelegung(ref QpEnrPos_COM[] Input);
public void CreateMultipleNewEsnBelegung(ref QpEnrPos_COM[] Input)
{
List<Domain.Entities.QpEnrPos> qpEnrPos = new List<Domain.Entities.QpEnrPos>();
foreach (var item in Input)
{
qpEnrPos.Add(ComConverter.ConvertQpEnrPosComToQpEnrPos(item));
}
Methods.CreateMultipleNewESNPos(qpEnrPos);
}
My VB code:
Dim qpenrPos(1) As CrossCutting_Application_ESN.QpEnrPos_COM
Set qpenrPos(0) = secondimportModel
Set qpenrPos(1) = firstimportModel
obj.CreateMultipleNewEsnBelegung (qpenrPos())
I know I need to do something with MarshalAs. However, I can't find the right way to do it.
obj.CreateMultipleNewEsnBelegung (qpenrPos())line, remove them.