W
wuherong2000
Unregistered / Unconfirmed
GUEST, unregistred user!
我用IntraWeb隨便寫一個測試程式,在Program情況下編譯成功,但是改成library時卻出錯,出錯信息為:
My Intraweb Application Error
Session not found. Session may have expired.
程式代碼很簡單就是做一登入窗體,登入後出現一畫面可以修改用戶密碼,我測試IWdll.dll時是這樣做的,我已經啟動了iis服務,建一虛擬目錄AWEB指向我程式所在文件夾,IWservercontroller的BoundIP沒設定,Port=1234,我在瀏覽器中輸入http://127.0.0.1/AWEB/Iwdll.dll/start後顯示上面的錯誤信息,程式碼比較少,我就列出來了,請各位幫助指正,急盼回復
library IWDll;//工程單元
{PUBDIST}
uses
IWInitISAPI,
ServerController in 'ServerController.pas' {IWServerController: TDataModule},
IWUnit1 in 'IWUnit1.pas' {formMain: TIWForm1},
DatamoduleUnit in 'DatamoduleUnit.pas' {DM: TDataModule},
MainMy in 'MainMy.pas' {formMainMy: TIWAppForm},
Common in 'Common.pas';
{$R *.res}
begin
IWRun(TFormMain, TIWServerController);
end.
unit DatamoduleUnit;//數據模塊單元
interface
uses
{$IFDEF Linux}QForms, {$ELSE}Forms, {$ENDIF}
SysUtils, Classes, DB, ADODB;
type
TDM = class(TDataModule)
conn: TADOConnection;
adoqUsers: TADOQuery;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
private
public
end;
function DM: TDM;
implementation
{$R *.dfm}
uses
IWInit,
ServerController;
function DM: TDM;
begin
Result := TUserSession(RWebApplication.Data).DM;
end;
procedure TDM.DataModuleCreate(Sender: TObject);
begin
conn.Connected :=true;
end;
procedure TDM.DataModuleDestroy(Sender: TObject);
begin
conn.Connected :=false;
end;
end.
unit Common;//公用單元
interface
uses DB,Classes,SysUtils,IWInit, IWTypes,IWAppForm, IWCompListbox;
procedure Move(AFormClass: TIWAppFormClass);
implementation
procedure Move(AFormClass: TIWAppFormClass);
begin
TIWAppForm(RWebApplication.ActiveForm).Release;
AFormClass.Create(RWebApplication).Show;
end;
end.
unit ServerController;//服務控制單元
interface
uses
Classes,
DatamoduleUnit,
IWServerControllerBase, IWAppForm, IWApplication,
SysUtils;
type
TIWServerController = class(TIWServerControllerBase)
procedure IWServerControllerBaseNewSession(ASession: TIWApplication;
var VMainForm: TIWAppForm);
private
public
end;
TUserSession = class(TComponent)
public
DM: TDM;
constructor Create(AOwner: TComponent); override;
end;
function UserSession: TUserSession;
implementation
{$R *.dfm}
uses
IWInit;
function UserSession: TUserSession;
begin
Result := TUserSession(RWebApplication.Data);
end;
constructor TUserSession.Create(AOwner: TComponent);
begin
inherited;
DM := TDM.Create(AOwner);
end;
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWAppForm);
begin
ASession.Data := TUserSession.Create(ASession);
end;
end.
unit IWUnit1;//登入驗證單元
interface
uses
IWAppForm, IWApplication, IWTypes, IWCompButton, Classes, Controls,
IWControl, IWCompEdit,Variants, IWCompLabel;
type
TformMain = class(TIWAppForm)
IWEdit1: TIWEdit;
IWEdit2: TIWEdit;
IWButton1: TIWButton;
IWLabel1: TIWLabel;
IWLabel2: TIWLabel;
IWButton2: TIWButton;
procedure IWButton1Click(Sender: TObject);
public
end;
implementation
{$R *.dfm}
uses
ServerController, DatamoduleUnit, Common, MainMy;
procedure TformMain.IWButton1Click(Sender: TObject);
begin
dm.adoqUsers.Open;
if dm.adoqUsers.Locate('UserName;Password',vararrayof
([iwedit1.Text,iwedit2.Text]),[]) then
begin
//webapplication.ShowMessage('you are logon')
Move(TFormMainMy);
end
else
webapplication.ShowMessage('you are no logoned');
end;
end.
unit MainMy;//修改密碼單元
interface
uses
IWAppForm, IWApplication, IWTypes, DB, IWDBStdCtrls, IWCompEdit, Classes,
Controls, IWControl, IWGrids, IWDBGrids, IWCompLabel;
type
TformMainMy = class(TIWAppForm)
IWDBGrid1: TIWDBGrid;
IWDBEdit1: TIWDBEdit;
IWDBEdit2: TIWDBEdit;
IWDBEdit3: TIWDBEdit;
IWDBNavigator1: TIWDBNavigator;
Ds: TDataSource;
IWLabel1: TIWLabel;
IWLabel2: TIWLabel;
IWLabel3: TIWLabel;
public
end;
implementation
{$R *.dfm}
uses
ServerController, DatamoduleUnit;
end.
My Intraweb Application Error
Session not found. Session may have expired.
程式代碼很簡單就是做一登入窗體,登入後出現一畫面可以修改用戶密碼,我測試IWdll.dll時是這樣做的,我已經啟動了iis服務,建一虛擬目錄AWEB指向我程式所在文件夾,IWservercontroller的BoundIP沒設定,Port=1234,我在瀏覽器中輸入http://127.0.0.1/AWEB/Iwdll.dll/start後顯示上面的錯誤信息,程式碼比較少,我就列出來了,請各位幫助指正,急盼回復
library IWDll;//工程單元
{PUBDIST}
uses
IWInitISAPI,
ServerController in 'ServerController.pas' {IWServerController: TDataModule},
IWUnit1 in 'IWUnit1.pas' {formMain: TIWForm1},
DatamoduleUnit in 'DatamoduleUnit.pas' {DM: TDataModule},
MainMy in 'MainMy.pas' {formMainMy: TIWAppForm},
Common in 'Common.pas';
{$R *.res}
begin
IWRun(TFormMain, TIWServerController);
end.
unit DatamoduleUnit;//數據模塊單元
interface
uses
{$IFDEF Linux}QForms, {$ELSE}Forms, {$ENDIF}
SysUtils, Classes, DB, ADODB;
type
TDM = class(TDataModule)
conn: TADOConnection;
adoqUsers: TADOQuery;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
private
public
end;
function DM: TDM;
implementation
{$R *.dfm}
uses
IWInit,
ServerController;
function DM: TDM;
begin
Result := TUserSession(RWebApplication.Data).DM;
end;
procedure TDM.DataModuleCreate(Sender: TObject);
begin
conn.Connected :=true;
end;
procedure TDM.DataModuleDestroy(Sender: TObject);
begin
conn.Connected :=false;
end;
end.
unit Common;//公用單元
interface
uses DB,Classes,SysUtils,IWInit, IWTypes,IWAppForm, IWCompListbox;
procedure Move(AFormClass: TIWAppFormClass);
implementation
procedure Move(AFormClass: TIWAppFormClass);
begin
TIWAppForm(RWebApplication.ActiveForm).Release;
AFormClass.Create(RWebApplication).Show;
end;
end.
unit ServerController;//服務控制單元
interface
uses
Classes,
DatamoduleUnit,
IWServerControllerBase, IWAppForm, IWApplication,
SysUtils;
type
TIWServerController = class(TIWServerControllerBase)
procedure IWServerControllerBaseNewSession(ASession: TIWApplication;
var VMainForm: TIWAppForm);
private
public
end;
TUserSession = class(TComponent)
public
DM: TDM;
constructor Create(AOwner: TComponent); override;
end;
function UserSession: TUserSession;
implementation
{$R *.dfm}
uses
IWInit;
function UserSession: TUserSession;
begin
Result := TUserSession(RWebApplication.Data);
end;
constructor TUserSession.Create(AOwner: TComponent);
begin
inherited;
DM := TDM.Create(AOwner);
end;
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWAppForm);
begin
ASession.Data := TUserSession.Create(ASession);
end;
end.
unit IWUnit1;//登入驗證單元
interface
uses
IWAppForm, IWApplication, IWTypes, IWCompButton, Classes, Controls,
IWControl, IWCompEdit,Variants, IWCompLabel;
type
TformMain = class(TIWAppForm)
IWEdit1: TIWEdit;
IWEdit2: TIWEdit;
IWButton1: TIWButton;
IWLabel1: TIWLabel;
IWLabel2: TIWLabel;
IWButton2: TIWButton;
procedure IWButton1Click(Sender: TObject);
public
end;
implementation
{$R *.dfm}
uses
ServerController, DatamoduleUnit, Common, MainMy;
procedure TformMain.IWButton1Click(Sender: TObject);
begin
dm.adoqUsers.Open;
if dm.adoqUsers.Locate('UserName;Password',vararrayof
([iwedit1.Text,iwedit2.Text]),[]) then
begin
//webapplication.ShowMessage('you are logon')
Move(TFormMainMy);
end
else
webapplication.ShowMessage('you are no logoned');
end;
end.
unit MainMy;//修改密碼單元
interface
uses
IWAppForm, IWApplication, IWTypes, DB, IWDBStdCtrls, IWCompEdit, Classes,
Controls, IWControl, IWGrids, IWDBGrids, IWCompLabel;
type
TformMainMy = class(TIWAppForm)
IWDBGrid1: TIWDBGrid;
IWDBEdit1: TIWDBEdit;
IWDBEdit2: TIWDBEdit;
IWDBEdit3: TIWDBEdit;
IWDBNavigator1: TIWDBNavigator;
Ds: TDataSource;
IWLabel1: TIWLabel;
IWLabel2: TIWLabel;
IWLabel3: TIWLabel;
public
end;
implementation
{$R *.dfm}
uses
ServerController, DatamoduleUnit;
end.