var
ConnectionService := TConnService;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
ConnectionService := TConnService.Create(Application);
end;
destructor TfrmMain.Destroy;
begin
ConnectionService.Free//执行这里时出错,原因使用Application当Owner
//,在这之前Application自动把ConnectionService释放掉了(把Owner为Application的都释放掉了)
inherited;
end;
这样会出错,frmMain为Application的主窗体