RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2233: Property '%s' inaccessible here (Delphi)

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.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!