EFilerError
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
EFilerError is raised when Delphi cannot read or write component data to or from a stream. This most often happens when loading a DFM form file that references a component class that is not registered, or when stream data is corrupt or mismatched. Check that all custom component packages are installed and that DFM files match the current component versions.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- A DFM file references a custom component whose package is not installed in the IDE or linked into the project
- A component was renamed or removed but the DFM still contains the old class name
- Streaming a component to a file and then trying to load it with a different or updated version of the component
- Manually editing a DFM file and introducing a syntax error or mismatched braces
- Using TReader or TWriter with a stream that has been corrupted or truncated
How to Fix It
-
When EFilerError fires at form load time, note the error message — it usually names the unrecognized class or property. Search the DFM text for that name.
Right-click the form in the IDE and choose View as Text to see the raw DFM content.
-
If the error names an unknown component class, install the missing package. Go to Component → Install Packages and add the package containing the class, or add the unit to the project's uses clause.
The component class must be registered with RegisterClass for the streaming system to recognize it.
-
If a component was deleted from the project but remains in the DFM, open the DFM as text and manually remove the entire block for the missing component. Save and re-open the form.
Delphi cannot remove the DFM entry automatically if it does not know the class — you must do it by hand in text mode.
-
After editing a DFM manually, validate the structure. Every object block must start with object ClassName: TClass and end with end. Mismatched blocks cause EFilerError on load.
The IDE sometimes refuses to open a DFM with structural errors — fix the text, then re-open.
-
If you are using TReader/TWriter in code, ensure the stream position is at the start before reading, and that the data was written by the same version of the component.
Stream data written by one version of a component may be incompatible with a newer version that has added or removed properties.
When to Call a Professional
EFilerError during form loading usually means the DFM and the code are out of sync. Open the DFM as text (right-click the form, View as Text) and look for component class names that do not match anything installed. For custom components, ensure the runtime package is added to the project and the design-time package is installed in the IDE.
Frequently Asked Questions
What is the difference between EFilerError, EReadError, and EWriteError?
EFilerError is the base class for all streaming errors. EReadError is raised specifically when a read operation from a stream fails. EWriteError is raised specifically when a write operation to a stream fails. All three share the same cause category — problems with component data serialization.
Why does my form open fine in the IDE but fail at runtime?
The IDE loads forms using design-time packages, which may include components not linked into the runtime executable. At runtime, only units and packages actually included in the project are available. Add the missing component's unit to the project's uses clause or add its runtime package to the project requirements.
Can I prevent EFilerError when loading user-saved data?
Yes. Wrap the stream-loading code in try/except and catch EFilerError. Log the error and either show a message to the user or fall back to default values. This prevents a corrupt or outdated save file from crashing the application.