EReadError
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
EReadError is raised when Delphi cannot read a component property from a stream or DFM file. This is a subclass of EFilerError and usually means the stream data does not match the component's expected properties. Common causes are missing component registrations, renamed properties, or corrupted stream data.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- A DFM file contains a property name that no longer exists in the component (property was renamed or removed)
- The component class is not registered, so the streaming system cannot find it to read its properties
- Stream data is truncated or corrupted, causing reads past the end of valid data
- A property's type changed between versions, making old streamed data incompatible
- Manually editing a DFM file and creating a malformed property value
How to Fix It
-
Check the exception message carefully. EReadError usually says something like 'Error reading FormName.ComponentName.PropertyName: ...' — note which property failed.
The full message is visible in the debugger's exception dialog and often in the IDE's Messages panel.
-
Open the DFM as text (right-click form, View as Text) and search for the property name mentioned in the error. Remove or correct the problematic property entry.
After editing the DFM as text, save and close the file, then re-open the form in the IDE.
-
If the property was removed from a custom component, implement DefineProperties in the component to silently skip the old property when streaming. This avoids EReadError when loading old files.
DefineProperties lets you define custom read/write procedures for properties that are not published, including ones that were removed.
-
If the stream data is from a file the user saved (not a DFM), wrap the load in try/except and handle EReadError by falling back to defaults and informing the user the file may be from an older version.
Never let a corrupt or outdated save file crash the application — always have a fallback.
-
Ensure all custom component packages are installed and linked. A missing component causes EReadError because the streaming system cannot find the class to read properties into.
The component class must be registered — either by calling RegisterClass or by having its unit included in the project.
When to Call a Professional
EReadError during form loading means the DFM contains something the current component cannot accept. Check the IDE output — it usually names the property that caused the failure. For removed properties, use the DefineProperties method in your component to handle old property names gracefully.
Frequently Asked Questions
What is the difference between EReadError and EFilerError?
EFilerError is the parent class for all streaming errors. EReadError is the specific subclass raised when a read operation fails. EWriteError is the specific subclass raised when a write operation fails. You can catch EFilerError to handle both read and write errors together.
Can Delphi skip unknown properties instead of raising EReadError?
By default, no — an unknown property raises EReadError. You can install a custom TReader.OnError event handler to ignore specific errors during streaming. Alternatively, implement DefineProperties in your component to handle old or alternative property names explicitly.
Why does EReadError only happen with some users and not others?
If the error occurs loading a user-saved file, it means those users saved the file with a different version of the application that had different component properties. Users who always use the current version will not encounter the problem. Version-safe streaming with DefineProperties or a custom file format solves this.