I've recently had need to produce an interop assembly. After some googling I discovered tlbimp.exe
. My next problem was that my COM library did not come with a .tlb
file. Further googling revealed that the type lib is often included as a resource in an exe/dll. Sure enough, opening the exe in VS2010 revealed it's type lib and a right-click later I had a tlb file to use with tlbimp
. Awesome.
However this is not a very nice process. Should I need to do this in the future, is there a way of extracting a Type Lib (.tlb file) from a .exe using the command line?
Tlbimp.exe can handle a type library resource inside an EXE just fine. For example:
Automating this is fairly risky btw. A type library is quite equivalent to an assembly reference. If it changed you want to know about it. Not just because you may well have to modify your interop code and retest it, DLL Hell is knocking on your door as well.