An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll

0

I'm trying to call a method from an old VB DLL and getting this error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll Additional information: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

This is a VB project using VS Community 2015. It successfully loads the dll but won't execute a method. I have source code for an older version of a program that makes the same call and using it as a guide. Included was a sample executable using that code which still works even though I'm on a 64bit Windows box and surely it was written a long time ago on an x86 box.

Here is the old code: The following 2 lines are called first in an earlier sub...

Dim SFServ As Object
Set SFServ = CreateObject("TC2000Dev.cTC2000") 'initialize dll

Private Sub FillListNames()
    Dim Names() As String
    Dim ListTypes() As Long

    'This call returns an array of ChartListNames and an array of their types
    SFServ.GetAllChartLists Names(), ListTypes() 'then it does stuff with Names etc

End Sub

Now here is the new code. The error occurs on line SFServ.GetAllCharLists

Dim SFServ As Object
SFServ = CreateObject("TC2000Dev.cTC2000")

Private Sub FillListNames()
    Dim Names() As String
    Dim ListTypes() As Long

    'This call returns an array of ChartListNames and an array of their types
    SFServ.GetAllChartLists(Names, ListTypes)
End Sub
vb.net
dll
asked on Stack Overflow Jan 22, 2017 by user3217883

1 Answer

-1

Just curious as I'm accessing TC2000 v7 for data in an Access project, but did you ever resolve this? I'm wondering if you need the directive Option Base 1 since you were working with cTC2000. cTC2005 was added for compatibility with the default for VBA, Option Base 0.

Might I also suggest that you early bind to the ActiveX object as:

Dim SFServ As TC2000Dev.cTC2000

since whis will provide the autoline function.

What was your project?

answered on Stack Overflow Aug 18, 2019 by Paul1307 • edited Aug 19, 2019 by Paul1307

User contributions licensed under CC BY-SA 3.0