Registration for COM Interoperability and Make COM Assembly Visible

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

Registration for COM Interoperability
These parameters perform the regam on the assembly and register the assembly as a COM component (or maybe not) in the registry with all COMs as registry entries. Is a TLB file created at this point? What else is done?

Sometimes I see that tlb is generated when compiling a project, but sometimes not, why is this so?

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

[GuidAttribute("02810C22-3FF2-4fc2-A7FD-5E103446DEB0"), ComVisible(true)] public interface IMyInterface { } 
+63
visual-studio compiler-options com-interop
Sep 13 '10 at 10:58
source share
2 answers

Make COM Assembly Visible is a great hammer to make all public assembly types [ComVisible]. It is highly desirable that you will need to select the specific types that you want to see, for example, in your fragment.

After assembly, the assembly must be registered so that the COM client can find it. Which uses only a number to identify the object that it wants to create, a GUID, an additional search is needed to find out what the DLL implements. Registration includes a record of keys in the HKLM\Software\Classes\CLSID\{guid} registry key. You can do this yourself by running Regasm.exe /codebase /tlb , or you can leave it on the build system to do this automatically after assembling the build.

What is Registration for COM Interoperability? This is desirable because it ensures that an old copy of the DLL is automatically registered before being overwritten, which prevents registry corruption. VS needs to be run with increased access in order to have write access to these registry keys, which is one of the reasons to make it optional. Or you simply do not want to register it, which is common on build servers. I can not comment on why you sometimes do not get .tlb without additional diagnostics.

+95
Sep 13 '10 at 11:43 on
source share

In addition to the comments made in the selected answer ,. The tlb file is not created if the types or methods have changed without first deleting the corresponding entry from the Windows registry (or closing the application or service using the library) using the / As parameter of the RegAsm utility:

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

It is also important to note that the registry for using the library as COM will only work on the developer's machine if it is compiled using the Register options for COM and Make Assembly COM-Visible interaction . You must register it manually on each target computer using the specified command line or by creating a script that runs when the library is installed.

I apologize for posting comments as an answer, but I can not post comments in the message, as I request 50 reputation points.

0
Jan 17 '19 at 16:15
source share



All Articles