HomeDelphiDelphi Error – E2137 Method ‘%s’ not found in base class

Delphi Error – E2137 Method ‘%s’ not found in base class

Delphi Compiler Error

E2137 Method ‘%s’ not found in base class

Reason for the Error & Solution

You have applied the ‘override’ directive to a method, but the compiler is unable to find a procedure of the same name in the base class.

program Produce;

  type
    Base = class
      procedure Title; virtual;
    end;

    Derived = class (Base)
      procedure Titl; override;
    end;

    procedure Base.Title;
    begin
    end;

    procedure Derived.Titl;
    begin
    end;

begin
end.

A common cause of this error is a simple typographical error in your source code. Make sure that the name used as the ‘override’ procedure is spelled the same as it is in the base class. In other situations, the base class will not provide the desired procedure: it is those situations which will require much deeper analysis to determine how to solve the problem.

program Solve;

  type
    Base = class
      procedure Title; virtual;
    end;

    Derived = class (Base)
      procedure Title; override;
    end;

    procedure Base.Title;
    begin
    end;

    procedure Derived.Title;
    begin
    end;

begin
end.

The solution (in this example) was to correct the spelling of the procedure name in Derived.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...