"Register for COM Interop" vs "Make assembly COM visible"

"Make assembly COM visible" is a big hammer to make all public types in the assembly [ComVisible]. Rarely desirable, you will want to select the specific types that you want to be visible, like you did in your snippet.

After the assembly is built, it needs to be registered so that a COM client can find it back. Which only uses a number to identify the object he wants to create, the GUID, an extra lookup is necessary to find out what DLL implements it. Registering involves writing keys in the HKLM\Software\Classes\CLSID\{guid} portion of the registry. You can do it yourself by running Regasm.exe /codebase /tlb or you can leave it up to the build system to do it automatically after building the assembly.

Which is what "Register for COM interop" does. It is desirable since it ensures that the old copy of the DLL gets unregistered automatically before it is overwritten, that prevents registry pollution. VS needs to run elevated to have write access to those registry keys, one reason for making it optional. Or you just don't want to register it, common on build servers. I can't comment on why you'd sometimes not get the .tlb without more diagnostics.


In addition to the accepted answer, the .tlb file is not created if the types or methods changed without first removing the corresponding record from the Windows's Registry (or closing the application or service that use the library), using the /U option of the RegAsm utility:

Regasm.exe yourlibrary.dll /codebase /tlb /u

Also, it is important to mention that the registry for consumption of the library as COM, will only work in the development machine if it is compiled using the options Register for COM interop and Make assembly COM-Visible. It is necessary to register it manually in each destination computer using the indicated command line or, generating an script that is executed when the library is installed.