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