Class '<classname>' has no accessible 'Sub New' and cannot be inherited

A class uses an Inherits Statement to specify a base class, but it cannot access any constructor on the intended base class.

This can happen if the intended base class has no constructors or if it has constructors with access levels that prevent access from another class.

When you inherit a class, your constructor should call the base class constructor using MyBase. If you do not make this call, or if you do not even write an explicit constructor, Visual Basic generates an implicit constructor that calls MyBase.New().

Error ID: BC31399

To correct this error

  1. If you have source control over the intended base class, then change the access level of at least one of its constructors so that another class can access them.

  2. If you cannot change the access levels of the intended base class constructors, then inherit from a different class or not at all.

See Also

Concepts

Inheritance Basics

Access Levels in Visual Basic

Reference

Inherits Statement

MyBase

New (Visual Basic)