Johny Bony
Johny Bony

Reputation: 373

EReadError - Invalid property value when I try to create Delphi unit

I am trying to create and run new Delphi application. But in the project file below I got this error when I try to CreateForm: Debugger Exception: Project ... raised exception class EReadError with message Invalid property value. Proces stoped.

program Project1;

uses
  Forms,
  OCR in 'OCR.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.Title := 'OCR';
  Application.CreateForm(TForm1, OCR1);
  Application.Run;
end.

Unit:

unit OCR;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
  public
    procedure FormCreate(Sender: TObject);
  end;

var
  OCR1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var list: TStringList;
begin
list := TStringList.create;
list.loadFromFile('OCR.txt');

end;

end.

DFM file:

object Form1: TForm1
  Left = 210
  Top = 181
  Width = 544
  Height = 375
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
end

I try to run the FormCreate function. What I have done is that in Object Inspector -> Form1 ... Events ... I have set OnCreate: FormCreate. This has been created on Delphi 7. What's the problem here?

But then this error happens.

Upvotes: 2

Views: 2719

Answers (1)

David Heffernan
David Heffernan

Reputation: 612884

Event handlers need to be published in order for the streaming framework to find them. You need to declare FormCreate as published rather than public.

Upvotes: 6

Related Questions