EClassNotFound

Delphi Programming Language

Severity: Moderate

What it means

The message names the class, such as Class TLabel not found.
Embarcadero: EClassNotFound is raised when a class that hasn't been linked into the application turns up while a component is read from a stream, usually a form file (.dfm).
Its example: a component exists on a form, but has been removed from the type declaration.

Affected Models

  • Delphi programs at run time

How to Fix It

  1. Look for the component in the form's class declaration. Missing? Stack Overflow's accepted answer: select it on the form, cut it and paste it back. Delphi adds the declaration, and the unit it needs.

  2. Check the components are declared at the top of the class, before private or public. Stack Overflow: a public line at the very top of a form's class gives Class not found errors at run time.

  3. A class that's only in the .dfm, or loaded from a file at run time, such as a report? Embarcadero: classes not referenced in a form declaration must be registered. Add the unit to a uses clause, and call RegisterClass for the class in its initialization section.

  4. A frame copied from another project? Stack Overflow: inherited lines left in its .dfm, with no real ancestor behind them, cause it. Change inherited to object in those lines.