Ad Space — Top Banner

Form Class Not Registered

Delphi Programming Language

Severity: Moderate

What Does This Error Mean?

This error means Delphi tried to create a form by its class name but could not find that class registered in the system. Form classes must be registered — either by being listed in the project's auto-create forms, or by having their unit included in the project so RegisterClass runs. The fix is to include the form's unit in the project and ensure it is in the uses clause.

Affected Models

  • Delphi 10.4 Sydney
  • Delphi 11 Alexandria
  • Delphi 12 Athens
  • Embarcadero RAD Studio
  • Free Pascal / Lazarus

Common Causes

  • The form's unit is not included in the project (.dpr file) and so its class is never registered
  • The form was removed from Project → Forms (auto-create or available forms list) but its class is still referenced
  • Using Application.CreateForm with a class name from a unit that is not in the uses clause
  • Loading a DFM that references a form class from an unlinked package or unit
  • A class name typo when using CreateForm or stream loading

How to Fix It

  1. Open Project → Forms (or Project Manager). Check whether the missing form is listed. If not, add it: Project → Add to Project and select the form's .pas file.

    Forms not in the project are not compiled and their classes are never registered with Delphi's class registry.

  2. Check the DPR file (the main program file). Every form that should be available must have its unit in the DPR uses clause. Delphi adds these automatically when you use Project → Add to Project.

    Open the DPR via Project → View Source. The uses clause lists all included units.

  3. If you are using Application.CreateForm, verify the class name matches exactly: Application.CreateForm(TMyForm, MyForm) — TMyForm must be the exact class name as declared in the form's unit.

    Class names are case-insensitive in Delphi but must match the actual declaration. A typo like TmyForm vs TMyForm can cause confusion even though Delphi is case-insensitive.

  4. For forms created dynamically (not in the auto-create list), make sure the form's unit is still in the uses clause of whichever unit creates it: uses MyFormUnit; ... MyForm := TMyForm.Create(Application);

    Including the unit in uses is what causes the unit's initialization to run and the class to be registered.

  5. If loading forms from a DFM stream or resource at runtime, ensure all form classes in that DFM are registered. Call RegisterClass(TMyForm) explicitly if the auto-registration has not occurred.

    RegisterClass is called automatically when a unit is initialized, but only if that unit is actually linked into the executable.

When to Call a Professional

If a form class is not registered, the application cannot create it at all. Open Project Manager (View → Project Manager) and check that the form's unit is listed. Also check Project → Forms to see whether the form is in the auto-create or available list. Adding the unit to the DPR's uses clause (directly or through Project → Add to Project) fixes the problem.

Frequently Asked Questions

What does RegisterClass do and why is it needed?

RegisterClass stores the class name and its class reference in a global registry so Delphi can look up a class by its name string. This is used by the streaming system (DFM loading) and by Application.CreateForm to find a class at runtime. Delphi form units call RegisterClass automatically in their initialization section — but only if the unit is included in the project.

Can a form be available without being in the auto-create list?

Yes. The auto-create list in Project → Forms determines which forms are created automatically at startup. Forms in the available list (not auto-create) are compiled and registered but not created until your code creates them explicitly. Both lists require the form's unit to be in the project.

Why does the error only happen at runtime and not at compile time?

The class registry lookup happens at runtime when Application.CreateForm or the streaming system tries to find the class. At compile time, Delphi only checks that the syntax is correct — it cannot detect a missing runtime registration. This is why the project compiles successfully but fails when the form is actually created.