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:
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>
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.
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.
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.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With