Need ClassInterfaceType.None?

  • Failed to get the following from MSDN :

    ClassInterfaceType.None

    Indicates that the class interface is not generated for the class. If no interfaces are explicitly implemented, the class can only provide late access through the IDispatch

    interface. This is recommended for ClassInterfaceAttribute

    . Usage ClassInterfaceType.None

    is just a way to expose functionality through interfaces explicitly by a class.

  • Is [ComVisible(true)]

    COM Visibility Required?

+2


source to share


1 answer


See this blog post for an extension of the first issue. The point is that if you don't specify ClassInterfaceType.None

, an additional interface is generated and this can cause binary compatibility problems if you change the order of the methods, change their signatures, or remove some of them. A much better alternative is to explicitly define the interface and inherit your class from it by specifying ClassInterfaceType.None

.



ComVisible(true)

not required for COM visibility. By default, all public methods of public classes and all public COM classes are visible, all other objects are not COM visible. If you need to change this, you use the ComVisible attribute, typically to reduce the number of visible COM classes, because for each COM visible class, registry entries and library type entries are generated, which unnecessarily pollutes the registry and bloats the type library. IMO it is a good idea to explicitly mark all public objects with ComVisible.

+7


source







All Articles