'<derivedtypename>' cannot inherit from <type> '<constructedbasetypename>' because it expands the access of type '<internaltypename>' outside the assembly

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

The following code can generate this error.

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

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

Error ID: BC30922

To correct this error

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

    -or-

  • If you cannot adjust the access levels, do not use the restricted 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