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

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

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...