Cannot convert from system.collections.generic.list to string in Vba.collections

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

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

From C #, I call this function. As below:

 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 ran into this error

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

How to transfer a list from C # to vb6? Please help me.

+5
source share
1 answer

You need to create Microsoft.VisualBasic.Collection , add the values ​​from the List and only then pass it to the 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); 
+2
source

Source: https://habr.com/ru/post/1268222/


All Articles