HomeDelphiDelphi Error – E2228 A dispinterface type cannot have an ancestor interface

Delphi Error – E2228 A dispinterface type cannot have an ancestor interface

Delphi Compiler Error

E2228 A dispinterface type cannot have an ancestor interface

Reason for the Error & Solution

An interface type specified with dispinterface cannot specify an ancestor interface.

program Produce;

  type
    IBase = interface
    end;

    IExtend = dispinterface (IBase)
    ['{00000000-0000-0000-0000-000000000000}']

    end;

begin
end.

In the example above, the error is caused because IExtend attempts to specify an ancestor interface type.

program Solve;

  type
    IBase = interface
    end;

    IExtend = dispinterface
    ['{00000000-0000-0000-0000-000000000000}']

    end;

begin
end.

Generally there are two solutions when this error occurs: remove the ancestor interface declaration, or change the dispinterface into a regular interface type. In the example above, the former approach was taken.

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