PDA

View Full Version : IntraWeb Application dropping COM objects-Slightly of topic



Mark Butchers
28-11-2002, 12:37 PM
Hello there,

i'm currently writing an intraweb application and plan on having external COM objects for most of the processing. The problem is that the COM object is dropped as soon as the calling procedure is exited even though the COM object is declared in the user sessions data module ( not locally in the calling procedure ), I have tested the COM object in a normal windows application and the connection is retained until programmatically dropped.

Does anyone know of a way to make a session wide connection to a COM object.

The code im using is below

type
TdtmMain = class(TDataModule)
procedure DataModuleDestroy(Sender: TObject);
procedure DataModuleCreate(Sender: TObject);
private
FCOMObject: ICOMObject;
protected
public
property COMObject: ICOMObject read FCOMObject;
end;

function dtmMain: TdtmMain;

implementation

uses ServerController, IWInit, ComObj, Variants;

{$R *.dfm}

function dtmMain: TdtmMain;
begin
Result := TUserSession(RWebApplication.Data).Data;
end;

procedure TdtmMain.DataModuleCreate(Sender: TObject);
begin
//all data access is to be done through this interface
if not Assigned(COMObject) then
begin
FCOMObject:= CoCOMObject.Create;
Assert(Assigned(COMObject),'Unable to create instance of ICOMObject');
end;
end;

procedure TdtmMain.DataModuleDestroy(Sender: TObject);
begin
COMObject := nil;
end;

Many thanks

Mark

Mark Butchers
28-11-2002, 01:19 PM
Hi there,

I compiled it as an ISAPI dll and ran it through IIS and it works. So the problem appears to be in the standalone version only.

Cheers

Mark