The only type libary I was able to convert to .NET assembly was
InfTypeLibrary. Other libraries cause null-exception when calling
ConvertTypeLibraryToAssembly method. And I believe there's
something wrong with them as other (non-CATIA) tlbs get imported
successfully.
From this I conclude that your best way is to use
tlbimp.exe.
UPDATE Below goes a sample code to aid you:
Imports System.Runtime.InteropServices
Imports System.Reflection
Module Module1
Sub Main()
Dim asm As Assembly = LoadTypeLib("c:\CATIA\B22\intel_a\code\bin\InfTypeLib.tlb", "INFITF")
Dim tp As System.Type = asm.GetType("INFITF.Application")
CATTest()
End Sub
Private Function LoadTypeLib(ByVal inputDll As String, ByVal outputAssembly As String) As Assembly
Dim dllPath As String
dllPath = System.IO.Path.Combine( _
New IO.FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, _
"Interop." + outputAssembly + ".dll")
' start tlbimp.exe
Const TLBIMP As String = "c:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\tlbimp.exe"
Dim pr As Process
pr = Process.Start(TLBIMP, """" + inputDll + """ /out:""" + dllPath + """ /silent /namespace:" + outputAssembly)
pr.WaitForExit()
' load libary
Return Assembly.LoadFile(dllPath)
End Function
Private Sub CATTest()
MsgBox("CATTest")
Dim CATIA As INFITF.Application
CATIA = GetObject([Class]:="CATIA.Application")
MsgBox(CATIA.Caption)
End Sub
End Module