How to generate a TLB file without registering?

Jim picture Jim · Jun 5, 2014 · Viewed 8k times · Source

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>

Answer

Michael Krebs picture Michael Krebs · Oct 18, 2017

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"