Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

after loadpackage getclass is returning nil 1

Status
Not open for further replies.

bianchin

Programmer
Mar 26, 2006
19
0
0
BR
1)i'm testing the use of dynamic packages
2)in a package I create a unit with:
type
TTest=class(TPersistent)
public
s:string;
end;

implementation

initialization
RegisterClass(TTest);

finalization
UnRegisterClass(TTest);

end.

3)In the package projetc options I chose runtime and design time

4)i create a application with a button with:

var
m:HMODULE;
aclass:TPersistentClass;
begin
m:=LoadPackage('test.bpl');
if m<>0 then
begin
aclass:=GetClass('TTest');
if aclass=nil then
showmessage('error');
UnloadPackage(m);
end;
end;

5)all fine with m<>0

6)the problem is:
GetClass always returns nil
why it can´t find TTest

I am not registering TTest correctly?

Thanks in advance!
Ricardo
 
Mmmm... rings some bells... be sure your test application is compiled with run-time packages. If not, the main app is using a linked instance of the VCL and your package is loading another. GetClass will be querying the first VCL instance and your class will be registered in the second one.

Or something like that.

buho (A).

PS: Design time? Your object is not a component.

 
Hey, it works! It´s party time!
Thanks a lot, Buho!

I thought checking the "Build with run time packages" option would staticaly link it.

if I am right, I should use design time packages only if a component of this package will be in the object inspector in my application. Does it right?
 
Yes. Design time is only for components that will be used in the IDE designer. If it is not going to be "dropped" in the IDE no need for design time.

buho (A).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top