Delphi Error – E2176 Illegal type in OLE automation section: ‘%s’

Delphi Compiler Error

E2176 Illegal type in OLE automation section: ‘%s’

Reason for the Error & Solution

<typename> is not an allowed type in an OLE automation section. Only a small subset of all the valid Delphi language types are allowed in automation sections.

program Produce;

  type
    Base = class
      function GetC : Char;
      procedure SetC(c : Char);
    automated
      property Ch : Char read GetC write SetC dispid 151;
    end;

  procedure Base.SetC(c : Char);
  begin
  end;

  function Base.GetC : Char;
  begin GetC := '!';
  end;

begin
end.

Since the character type is not one allowed in the ‘automated’ section, the declaration of ‘Ch’ will produce an error when compiled.

program Solve;

  type
    Base = class
      function GetC : String;
      procedure SetC(c : String);
    automated
      property Ch : String read GetC write SetC dispid 151;
    end;

  procedure Base.SetC(c : String);
  begin
  end;

  function Base.GetC : String;
  begin GetC := '!';
  end;

begin
end.

There are two solutions to this problem. The first is to move the offending declaration out of the ‘automated’ section. The second is to change the offending type to one that is allowed 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...