Delphi – E2075 This form of method call only allowed in methods of derived types

If you try to call a method of an ancestor type but aren’t actually in a method, you’ll get this error message.

program Produce;

type
  TMyClass = class
    constructor Create;
  end;

procedure Create;
begin
  inherited Create;      (*<-- Error message here*)
end;

begin
end.

The example tries to call an inherited function in procedure Create, which is not a function.

program Solve;

type
  TMyClass = class
    constructor Create;
  end;

constructor TMyclass.Create;
begin
  inherited Create;
end;

begin
end.

When using this type of call, the solution is to make sure you’re in a method.

%d