Delphi Error – E2233 Property ‘%s’ inaccessible here

Delphi Compiler Error

E2233 Property ‘%s’ inaccessible here

Reason for the Error & Solution

An attempt has been made to access a property through a class reference type. It is not possible to access fields nor properties of a class through a class reference.

program Produce;

  type
    TBase = class
    public
      FX : Integer;
      property X : Integer read FX write FX;
    end;

    TBaseClass = class of TBase;

  var
    BaseRef : TBaseClass;
    x : Integer;

begin
  BaseRef := TBase;
  x := BaseRef.X;
end.

Attempting to access the property X in the example above causes the compiler to issue an error.

program Solve;

  type
    TBase = class
    public
      FX : Integer;
      property X : Integer read FX write FX;
    end;

    TBaseClass = class of TBase;

  var
    BaseRef : TBaseClass;
    x : Integer;

begin
  BaseRef := TBase;
end.

There is no other solution to this problem than to remove the offending property access from your source code. If you wish to access properties or fields of a class, then you need to create an instance variable of that class type and gain access through that variable.

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