Delphi Compiler Error
E2180 Dispid ‘%d’ already used by ‘%s’
Reason for the Error & Solution
An attempt to use a dispid which is already assigned to another member of this class.
program Produce; type Base = class v : Integer; procedure setV(x : Integer); function getV : Integer; automated property Value : Integer read getV write setV dispid 151; property SecondValue : Integer read getV write setV dispid 151; end; procedure Base.setV(x : Integer); begin v := x; end; function Base.getV : Integer; begin getV := v; end; begin end.
Each automated property’s dispid must be unique, thus SecondValue is in error.
program Solve; type Base = class v : Integer; procedure setV(x : Integer); function getV : Integer; automated property Value : Integer read getV write setV dispid 151; property SecondValue : Integer read getV write setV dispid 152; end; procedure Base.setV(x : Integer); begin v := x; end; function Base.getV : Integer; begin getV := v; end; begin end.
Giving a unique dispid to SecondValue will remove the error.