Delphi Error – E2180 Dispid ‘%d’ already used by ‘%s’

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.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...