Board index » delphi » load package dynamicly - run-time

load package dynamicly - run-time

My project meed to load package dynamicly - run-time
I try to run the below code.
It compile and run fine .
But when i try to exit the application i get an error.
 Exception class EInvalidPointer with massage "Invalid pointer operator"

The application ; Load dynamicly BPL

procedure TForm1.Button3Click(Sender: TObject);
var
 PackageModule: HModule;
 AClass: TPersistentClass;
begin

 PackageModule := LoadPackage('Pkg3.bpl');
 if PackageModule <> 0 then
 begin

   AClass := GetClass('TFrm_Connection');

   if AClass <> nil then
     with TComponentClass(AClass).Create(Application)
       as TForm do
     begin
       ShowModal;
       Free;
     end;

   UnloadPackage(PackageModule);
 end;

end;

in the BPL : in Form unit  i add  this code:

initialization
 RegisterClass(TFrm_Connection);

finalization
 UnRegisterClass(TFrm_Connection);

end.

 

Re:load package dynamicly - run-time


The code looks OK. Per se. Is the calling EXE built with packages?
What does the form do?

--
Robert

Quote
Asi wrote in message <3c4527a0_2@dnews>...
>My project meed to load package dynamicly - run-time
>I try to run the below code.
>It compile and run fine .
>But when i try to exit the application i get an error.
> Exception class EInvalidPointer with massage "Invalid pointer operator"

>The application ; Load dynamicly BPL

>procedure TForm1.Button3Click(Sender: TObject);
>var
> PackageModule: HModule;
> AClass: TPersistentClass;
>begin

> PackageModule := LoadPackage('Pkg3.bpl');
> if PackageModule <> 0 then
> begin

>   AClass := GetClass('TFrm_Connection');

>   if AClass <> nil then
>     with TComponentClass(AClass).Create(Application)
>       as TForm do
>     begin
>       ShowModal;
>       Free;
>     end;

>   UnloadPackage(PackageModule);
> end;

>end;

>in the BPL : in Form unit  i add  this code:

>initialization
> RegisterClass(TFrm_Connection);

>finalization
> UnRegisterClass(TFrm_Connection);

>end.

Re:load package dynamicly - run-time


regular task ... display task like dbgrid etc ...
Quote
"Robert Cerny" <robert.qwe.ce...@neosys.xrs.qwe.si> wrote in message

news:a23qut.4ig.1@neosys.xrs.si...
Quote
> The code looks OK. Per se. Is the calling EXE built with packages?
> What does the form do?

> --
> Robert

> Asi wrote in message <3c4527a0_2@dnews>...
> >My project meed to load package dynamicly - run-time
> >I try to run the below code.
> >It compile and run fine .
> >But when i try to exit the application i get an error.
> > Exception class EInvalidPointer with massage "Invalid pointer operator"

> >The application ; Load dynamicly BPL

> >procedure TForm1.Button3Click(Sender: TObject);
> >var
> > PackageModule: HModule;
> > AClass: TPersistentClass;
> >begin

> > PackageModule := LoadPackage('Pkg3.bpl');
> > if PackageModule <> 0 then
> > begin

> >   AClass := GetClass('TFrm_Connection');

> >   if AClass <> nil then
> >     with TComponentClass(AClass).Create(Application)
> >       as TForm do
> >     begin
> >       ShowModal;
> >       Free;
> >     end;

> >   UnloadPackage(PackageModule);
> > end;

> >end;

> >in the BPL : in Form unit  i add  this code:

> >initialization
> > RegisterClass(TFrm_Connection);

> >finalization
> > UnRegisterClass(TFrm_Connection);

> >end.

Other Threads