E2228 A dispinterface type cannot have an ancestor interface (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

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.