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

Viewed 52457

What is the real difference between these two options? What I know is:

Register for COM Interop
This options executes regasm on the assembly and registers the assembly as an COM component(or maybe not) in the registry with all COM like registry entries. Does this step generates a TLB file? What else is done?

Sometimes I see a tlb is generated when I compile the project but sometimes not, why is this?

Make assembly COM visible
What effect does this one has on an assembly? If I have the following type inside this assembly, do I still need to specify the "Make assembly COM Visible" even though my type is marked as ComVisible?

[GuidAttribute("02810C22-3FF2-4fc2-A7FD-5E103446DEB0"), ComVisible(true)]
public interface IMyInterface
{
}
2 Answers

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.

Related