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.