ComVisibleTypeBaseTypesShouldBeComVisible problem


  • I'm having CA1405:ComVisibleTypeBaseTypesShouldBeComVisible warning for a class derived from another. I checked the hierarchy its parent classes for ComVisible(false) since it says the class is marked ComVisible(true) but has the ComVisible(false) types in its object hierarchy. So I wonder in which class ComVisible(false) attribute has been set. The hierarchy involves interfaces IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable and as I checked none of them are invisible to the COM clients. I appreciate if someone can explain how this warning could come in this case.


    Thursday, April 26, 2012 2:05 AM


  • The resolution details for the violation should include a list of types that are not marked as COM-visible.  If this is not helpful, please note the following:

    • The rule examines the inheritance hierarchy, not the implemented interfaces.
    • A type is COM-visible only if it is marked with ComVisible(true).  It is not COM-visible if if has no ComVisible attribute.

    Based on the list of implemented interfaces you have provided, I would guess that you're probably inheriting from List<T>, which has no ComVisible attribute, so it is not actually COM-visible.

    Thursday, April 26, 2012 1:17 PM