Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot convert from system.collections.generic.list to string to Vba.collections

Tags:

c#

asp.net

vba

vb6

I want to pass a list of int from C# to a dll written in vb6 . In vb6 the prototype of function is as follows :

Public Function FamIdentify(agentList As Collection, strName As String, strIdentifyTemplate As String, strIP As String) As Boolean

From C# I am calling this function As follows :

public Boolean IdentifyFinger(String name, String SampleModel, String REMOTE_ADDR) 
{ 
List<int> agentList = new List<int>(); 
// insert some element to this list
FamServer.FamApp famApp = new FamServer.FamApp(); 
Boolean flag = famApp.FamIdentify(ref agentList, ref name, SampleModel, REMOTE_ADDR);
 return flag ; 
}

For this coding I am facing this error

cannot convert from system.collections.generic.list to string to Vba.collections

How can I pass list from C# to vb6 ? Please help me .

like image 693
Christopher Marlowe Avatar asked Oct 29 '22 07:10

Christopher Marlowe


1 Answers

You need to create Microsoft.VisualBasic.Collection, add values from List, and only then pass it to function. I think, there is no direct cast to Collection.

Microsoft.VisualBasic.Collection agentCollection= new Microsoft.VisualBasic.Collection();
agentList.ForEach(x=> agentCollection.Add(x));

Boolean flag = famApp.FamIdentify(ref agentCollection, ref name, SampleModel, REMOTE_ADDR);
like image 50
Mantas Čekanauskas Avatar answered Nov 13 '22 01:11

Mantas Čekanauskas