【发布时间】:2019-03-19 23:40:09
【问题描述】:
我有一个 .NET DLL,它用作 3rd 方应用程序的包装器。 DLL 为 COM-Interop 注册如下:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /tlb /codebase "C:\Dev\1) Source\TAC10_CAD\Lib\PowerPhoneInterface\PowerPhoneInterface.dll"
DLL 中有多个从 VB6 调用的方法。除了一个之外,所有工作都完美无缺。该方法的 .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。两者都没有成功。
我一直在谷歌上搜索,直到视力模糊,似乎无法找到电话的问题。
任何建议将不胜感激。
【问题讨论】:
-
如果是[可选],那么 VB6 运行时必须有办法指定程序员选择不通过它。这需要一个变体,C# 中的对象。您可能更喜欢 int SetAniAli(string eventType = ""),它对类型库中的可选值进行编码。
标签: vb6 com-interop