HomeDelphiDelphi Error – E2183 Dispid clause only allowed in OLE automation section

Delphi Error – E2183 Dispid clause only allowed in OLE automation section

Delphi Compiler Error

E2183 Dispid clause only allowed in OLE automation section

Reason for the Error & Solution

A dispid has been given to a property which is not in an automated section.

program Produce;

  type
     Base = class
       v : integer;
       procedure setV(x : integer);
       function getV : integer;
       property Value : 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.

This program attempts to set the dispid for an OLE automation object, but the property has not been declared in an automated section.

program Solve;

  type
     Base = class
       v : integer;
       procedure setV(x : integer);
       function getV : integer;
     automated
       property Value : 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.

To solve the error, you can either remove the dispid clause from the property declaration, or move the property declaration into an automated section.

Share:

Leave A Reply

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

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