无法从system.collections.generic.list转换为字符串到Vba.collections

时间:2017-05-25 09:36:38

标签: c# asp.net vba vb6

我想将C#中的int列表传递给用vb6编写的dll。在vb6中,函数的原型如下:

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

从C#我调用此函数如下:

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 ; 
}

对于此编码,我面临此错误

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

如何将列表从C#传递给vb6?请帮我 。

1 个答案:

答案 0 :(得分:2)

您需要创建Microsoft.VisualBasic.Collection,从List添加值,然后才将其传递给函数。我认为,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);