C #: Regasm generates registry entries for each class in my COM library?

I am writing a class library (IE BHO) in C # and am currently struggling with a large amount of what, in my opinion, is an undesirable result coming from the generated REGASM registry keys.

Short version: I want to show only a few classes (currently: ONE class) in IE (and the rest of COM). Only one class has a set of ClassInterfaceAttribute and GUID properties, and I can verify that the add-in only requires COM registry keys for this class - and yet REGASM generates GUIDs and registry keys for each class in the entire project.

This is annoying and somewhat worrying, since I do not want the names of my classes to be in the user registry, if they absolutely should not be there.

In fairness, we note that many of these classes are marked as public, because I use them in a driver application from another project in the same solution to get around IE by debugging a black hole ...

I'm still very green for COM in general (especially related to .Net), and I was wondering what is the best way to hide all my other classes from regasm? Or, at least, why do these classes, which, even though they are marked as public, appear when I did not set any of the COM flags for them?

Thanks!

+3
source share
4 answers

internal , public. , public, ComVisible, .

:

[ComVisible(false)]
public class ClassToHide {
    //whatever
};

public class ClassToExpose {

     public void MethodToExpose() {}

     [ComVisible(false)]
     public void MethodToHide() {}
};

- - - COM-. , , , COM ComVisible.

+5

/regfile - reg, .

.reg , , , . , , , .

, , .

+2

COM- .

, COM, DLL. COM- , . DLL.

, , public, internal .

+2

Set the ComVisible attribute to false in the AssemblyInfo file and set the applicable ComVisible method only for the desired classes.

+1
source

Source: https://habr.com/ru/post/1710822/


All Articles