Delphi Error – E2181 Redeclaration of property not allowed in OLE automation section

Delphi Compiler Error

E2181 Redeclaration of property not allowed in OLE automation section

Reason for the Error & Solution

It is not allowed to move the visibility of a property into an automated section.

program Produce;

  type
    Base = class
      v : Integer;
      s : String;
    protected
      property Name : String read s write s;
      property Value : Integer read v write v;
    end;

    Derived = class (Base)
    public
      property Name; (* Move Name to a public visibility by redeclaration *)
    automated
      property Value;
    end;

begin
end.

In the above example, Name is moved from a private visibility in Base to public visibility in Derived by redeclaration. The same idea is attempted on Value, but an error results.

program Solve;

  type
    Base = class
      v : Integer;
      s : String;
    protected
      property Name : String read s write s;
      property Value : Integer read v write v;
    end;

    Derived = class (Base)
    public
      property Name; (* Move Name to a public visibility by redeclaration *)
      property Value;
    automated
    end;

begin
end.

It is not possible to change the visibility of a property to an automated section, therefore the solution to this problem is to not redeclare properties of base classes in automated sections.

Share:

Leave A Reply

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

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...