Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a TLB file without registering?

I have a library with a public COM/ActiveX interface built in Visual Studio 2012. I have an installer for this library written with WiX. It all works pretty well, except that on my build server we'd like to build the installer without admin privileges.

Here's the problem, currently I have "Register for COM interop" checked. This both generates a TLB file, and registers the library at build time (I think.) Registering at build time requires admin privileges, so the build will fail if I don't build with them.

However, if I uncheck "Register for COM interop" so I can build without admin privileges, the TLB file is not generated. So my WiX installer fails to build.

I can see two possible solutions for this:

  1. Have some way to generate the TLB without actually registering it at build time.
  2. Have WiX generate the TLB. I haven't seen anyway to do this. My current TLB install stuff references the TLB file directly, like this: xml <File Id="FILE.COM.TLB" KeyPath="yes" Source="..\..\Master\Proj\bin\$(var.Configuration)\Proj.tlb"> <TypeLib Id="{8CC87042-4B1B-4FE4-86D5-A12C1A55C8AA}" Description="PrimProj" HelpDirectory="DIR.BIN.HELP" Language="0" MajorVersion="1" MinorVersion="3"> .... <snip> .... </TypeLib> </File>
like image 712
Jim Avatar asked Jun 04 '14 22:06

Jim


People also ask

How do I create a TLB file?

You need to just generate the TLB file, so tlbimp.exe is perhaps what you need since it generates the tlb without changing the system. Turns out that tlbimp.exe does the opposite of what I want, but it did point me in the right direction. tlbexp.exe is the correct command.

What does Tlbexp do?

Remarks. Tlbexp.exe generates a type library that contains definitions of the types defined in the assembly. Applications such as Visual Basic 6.0 can use the generated type library to bind to the . NET types defined in the assembly.

How do I register for typelib?

The correct registration entries for a type library can be generated by calling the RegisterTypeLib function on the type library. You can then use Regedit.exe to write the registration entries to a text file from the system registration database.


1 Answers

The tlb will not be built if the COM interop cannot be registered. Registering the COM interop might fail due to missing administrator privileges, for example.

"TlbExp.exe" is the command to build the tlb file. To use it, uncheck the "Register for COM interop" option on the compile tab of the project properties, so the build will stop failing to register. Then, add this as a post build event, by clicking the "Build Events..." button located on the same tab:

"$(FrameworkSdkDir)\bin\NETFX 4.0 Tools\tlbexp.exe" "$(TargetFileName)" "$(TargetName).tlb"  
like image 195
Michael Krebs Avatar answered Sep 17 '22 00:09

Michael Krebs