Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMVCController in DLL #22

Open
pieskov opened this issue Jul 24, 2017 · 0 comments
Open

TMVCController in DLL #22

pieskov opened this issue Jul 24, 2017 · 0 comments

Comments

@pieskov
Copy link

pieskov commented Jul 24, 2017

Hi.

How to use the TMVCController class in DLL?

In DLL
`...
TAdminCntrl = class(TMVCController)

end;

function getController(const AMVC: TMVCEngine): TMVCControllerClass; stdcall;

exports
getController;

implementation

uses
SysUtils, MVCFramework.Session, System.JSON;

function getController(const AMVC: TMVCEngine): TMVCControllerClass; stdcall;
begin
MVC := AMVC;
Result := TAdminCntrl;
end;
...`

In AppServer
... APath := GetDirectoryName(APath); Res := System.SysUtils.FindFirst(APath + '*.dll', faAnyFile, SR); try while Res = 0 do begin dll := LoadLibrary(PWideChar(APath + SR.Name)); if dll <> 0 then begin get_func := GetProcAddress(dll, 'getController'); FMVC.AddController(get_func(FMVC)); end; Res := FindNext(SR); end; finally System.SysUtils.FindClose(SR); end; ...

When you call this controller's method, the error "Invalid class typecast".

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant