• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1872
  • Last Modified:

Encountering an error using Tlbimp.exe

I have a VB6 program and need to expose its object model for use within a Visual Basic 2008 application.

I am using the Type Library Importer (Tlbimp.exe) to convert the type definitions found within the COM type library into equivalent definitions in a common language runtime assembly.

The Tlbimp.exe should emit a DLL file called a Primary Interop Assembly (PIA), but instead, it generates an error.

You help on this would be greatly appreciated.


The batch file command line is as follows:

call "%WindowsSDKPath%bin\tlbimp" %AppPath% /out:"%PIADir%\%PIAFile%" /keyfile:%KeyPath% /primary /verbose


The Tlbimp outputs the following error within the command prompt window:

TlbImp : error TI0000 : System.ApplicationException - Referenced type library 'VBA' does not have a primary interop assembly registered.
  • 2
2 Solutions
As far as I can see maybe the problem is that you are trying to publish a PIA that is referencing a library that is not a PIA. The only solution apparently is to create a wrapper to the required library.

Read here :
LeapingdogAuthor Commented:

Thanks for the feedback.  The link you sent me is not too specific on this top, but using a wrapper may be the way to handle the error.  

It is strange that I don't even reference VBA within the code, so I would not even know what to wrap.

LeapingdogAuthor Commented:
The solution:

The actual error was that I had public collection objects within my object model.  The collection objects must be private before TlbImp will work.

You can make the collection objects private using the following:

Function NewEnum() As IUnknown
    Set NewEnum = colPArrays.[_NewEnum]
End Function
'And setting the type to -4

Open in new window


Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now