I am trying to make a modular application in delphi2010 using BPL.
Problem is When I try to create class within BPL, I get this error message.

I didn’t do any operation about resource (RES file)!
Procedure TControllerMain.Btn1OnClick(Sender: TObject);
type
TInitProcedure = function: TModuleBaseClass; stdcall;
TModuleBaseClass= class of TModuleBase;
var
h: HMODULE;
proc: TInitProcedure;
vClass: TModuleBaseClass;
begin
h := LoadPackage('test.bpl');
@proc := GetProcAddress(h, 'InitializePlugin');
vClass := proc();
vClass.Create(nil); // error here
UnloadPackage(h);
end;
dll code
TModuleBase is a TCustomPanel
type
TVLCVideo = class(TModuleBase)
private
...
public
...
end;
function InitializePlugin: TModuleBaseClass; stdcall;
implementation
function InitializePlugin: TModuleBaseClass;
begin
Result := TVLCVideo;
end;
exports
InitializePlugin;
end.
The solution :
I was use TCustomPanel for ancestor of TModulBase but I was seen the problem, Remy is right. and them I remove the ancestor class for replace with a interface and all of my another plugins have to use same interface (if you using this way with normal dll project you will get a different error! I was try 🙁 you have to use it with bpl (bpl is a dll too))
this Button click is a just sample you have to create a modul manager class
Important things :
You cannot import the interface library file to module package file directly or in main application project! you have to create a new bpl project for just interface and shared library files, and them you need to put it your module packages in requires section like as vlc,rtl.
And you need to build main application with this interface package