1
votes

I have a .NET DLL that serves as a wrapper to a 3rd party application. The DLL is registered for COM-Interop as follows:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /tlb /codebase "C:\Dev\1) Source\TAC10_CAD\Lib\PowerPhoneInterface\PowerPhoneInterface.dll"

There are multiple methods in the DLL that are called from VB6. All work perfectly except one. The .NET function prototype for that method is as follows:

    int SetAniAli([Optional] string incidentType);

In VB6, I invoke the problematic method as follows:

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 is the object reference to my DLL. The first method call (SetCallerInformation) works great. In addition, there are two other DLL calls invoked from the function CheckPowerPhoneConnection that also work great. However, SetAniAli gives a "type mismatch" error every time. I have rc defined as a Long in VB6, but also tried Variant. No success with either.

I have googled until I get blurred vision and cannot seem to find what is wrong with the call.

Any suggestions would be greatly appreciated.

1
If it is [Optional] then there must a way for the VB6 runtime to specify that the programmer chose not to pass it. That requires a variant, object in C#. You might prefer int SetAniAli(string incidentType = ""), it encodes the optional value in the type library.Hans Passant

1 Answers

0
votes

I'm not sure if this is the reason or not, but I modified the SetAniAli method to make the incidentType parameter required vs optional and the problem is no more. If someone definitively knows that VB6 has a problem with optional parameters or if they require special handling on the VB6 side, please post a comment so that others can benefit.