Subject | RE: [IBO] TIB_Session in ISAPI DLL |
---|---|
Author | |
Post date | 2014-06-19T15:03:51Z |
I get an Access Violation because WebModule2=nil. To try to address this I moved the definitions to the TWebModule2 unit, but it didn't help - the library unit consists of (essentially)
begin
CoInitFlags := COINIT_MULTITHREADED;
Application.Initialize;
Application.CreateForm(TWebModule2, WebModule2);
Application.Run;
end.
The TWebModule2 unit now looks like this:
unit webint;
interface
uses ...
type
TAS_IBODatabase = class(TIBODatabase)
private
public
constructor Create(anOwner: TComponent); override;
end;
TAS_IBOQuery = class(TIBOQuery)
private
public
procedure Open;
constructor Create(anOwner: TComponent); override;
end;
TWebModule2 = class(TWebModule)
AS_DLL_SESSION: TIB_Session;
AS_DLL_TRANSACTION: TIBOTransaction;
procedure WebModule2USERLISTAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
...
end;
var
WebModule2: TWebModule2;
implementation
uses ...
constructor TAS_IBODatabase.Create(anOwner: TComponent);
begin
inherited Create(anOwner);
if Assigned(WebModule2) then
WriteErMsg('WebModule2 IS assigned')
else
WriteErMsg('WebModule2 IS NOT assigned');
IB_Session := WebModule2.AS_DLL_Session; {Generates AV}
WriteErMsg('Successfully executed "IB_Session:= WebModule2.AS_DLL_Session"');
end;
procedure TWebModule2.WebModule2USERLISTAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
...
begin
CoInitFlags := COINIT_MULTITHREADED;
Application.Initialize;
Application.CreateForm(TWebModule2, WebModule2);
Application.Run;
end.
The TWebModule2 unit now looks like this:
unit webint;
interface
uses ...
type
TAS_IBODatabase = class(TIBODatabase)
private
public
constructor Create(anOwner: TComponent); override;
end;
TAS_IBOQuery = class(TIBOQuery)
private
public
procedure Open;
constructor Create(anOwner: TComponent); override;
end;
TWebModule2 = class(TWebModule)
AS_DLL_SESSION: TIB_Session;
AS_DLL_TRANSACTION: TIBOTransaction;
procedure WebModule2USERLISTAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
...
end;
var
WebModule2: TWebModule2;
implementation
uses ...
constructor TAS_IBODatabase.Create(anOwner: TComponent);
begin
inherited Create(anOwner);
if Assigned(WebModule2) then
WriteErMsg('WebModule2 IS assigned')
else
WriteErMsg('WebModule2 IS NOT assigned');
IB_Session := WebModule2.AS_DLL_Session; {Generates AV}
WriteErMsg('Successfully executed "IB_Session:= WebModule2.AS_DLL_Session"');
end;
procedure TWebModule2.WebModule2USERLISTAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
...