在调用.NET DLL中的方法时,VB6中的类型不匹配

时间:2018-10-15 14:02:11

标签: vb6 com-interop

我有一个.NET DLL,可作为第三方应用程序的包装。 DLL为COM-Interop注册如下:

C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ RegAsm.exe / tlb /代码库“ C:\ Dev \ 1)Source \ TAC10_CAD \ Lib \ PowerPhoneInterface \ PowerPhoneInterface.dll”

从VB6调用的DLL中有多种方法。除了一个以外,其他所有工具都可以正常工作。该方法的.NET函数原型如下:

    int SetAniAli([Optional] string incidentType);

在VB6中,我按如下方式调用有问题的方法:

If GetSettingBitValue("G_POWERPHONE_ENABLE") Then
    If CheckPowerPhoneConnection() Then
        frmParent_Dispatch.PowerPhoneInterface.SetCallerInformation person, 
            phone, Callback, Address.FullText
        frmParent_Dispatch.PowerPhoneInterface.SetAniAli
        rc = frmParent_Dispatch.PowerPhoneInterface.SetAniAli
        If rc = 10 Then
            PowerPhoneCallInit = True
        Else
            Call modCAD.SetWarning("Attempt to set ANIALI information failed.")
        End If
    End If
End If

PowerPhoneInterface是对我的DLL的对象引用。第一个方法调用(SetCallerInformation)效果很好。此外,还有两个其他从函数CheckPowerPhoneConnection调用的DLL调用也可以正常工作。但是,SetAniAli每次都会出现“类型不匹配”错误。我在VB6中将rc定义为Long,但也尝试了Variant。两者都没有成功。

我一直用Google搜索,直到视力模糊并且似乎找不到通话的问题。

任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

我不确定这是否是原因,但是我修改了SetAniAli方法,使eventType参数为必需vs可选,问题不再存在。如果某人明确知道VB6的可选参数有问题,或者他们需要在VB6方面进行特殊处理,请发表评论,以便其他人可以受益。

相关问题