'<derivedtypename>' cannot inherit from <type> '<constructedbasetypename>' because it expands the access of type '<internaltypename>' to <region> '<regionname>'

A derived class or interface attempts to expand the access level of an internal type by using it as a type argument to a base class or interface.

The following code can generate this error.

Public Class containingClass
    Public Class baseClass(Of t)
    End Class
    Friend Class derivedClass
        Inherits baseClass(Of internalStructure)
    End Class
    Private Structure internalStructure
        Dim firstMember As Integer
    End Structure
End Class

Code outside containingClass is not allowed to access internalStructure. However, derivedClass can be accessed from any code in the same assembly. Therefore, derivedClass cannot inherit baseClass if it uses internalStructure as a type argument, because that could expose internalStructure throughout the defining code region.

Error ID: BC30921

To correct this error

  • Adjust the access levels of the classes or interfaces so that the derived type does not expand the access level of the internal type.

    -or-

  • If you cannot adjust the access levels, then do not use the internal type as a type argument when constructing the base class or interface.

See Also

Concepts

Inheritance Basics

Access Levels in Visual Basic

Generic Types in Visual Basic

Reference

Inherits Statement

Type List