Delphi Error – E2217 Published field ‘%s’ not a class or interface type

Delphi Compiler Error

E2217 Published field ‘%s’ not a class or interface type

Reason for the Error & Solution

An attempt has been made to publish a field in a class which is not a class nor interface type.

program Produce;

  type
    TBaseClass = class
    published
      x : Integer;
    end;
begin
end.

The program above generates an error because x is included in a published section, despite the fact that it is not of a type which can be published.

program Solve;
  type
    TBaseClass = class
      Fx : Integer;
    published
      property X : Integer read Fx write Fx;
    end;

begin
end.

To solve this problem, all fields which are not class nor interface types must be removed from the published section of a class. If it is a requirement that the field actually be published, then it can be accomplished by changing the field into a property, as was done in this example.

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