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.