[DUG] AV error with TServerObject
Grant Brown
grant at sitedoc.com.au
Tue Sep 20 13:55:43 NZST 2005
Hi all,
Using D5 and Midware components. ( I have list the class code used at
the bottom)
I have tried the midware mailing list but no success there.
The code compiles without any problems but I keep getting an access
violation when I try to access FUserData from a TServer Object excute
proceudre.
eg if not Assigned(FUserData) then raise Exception.Create('FUserData not
assigned');
Can some one please help me understand why the AV and how to resolve the
problem.
TIA
Regards
Grant. (the one with no hair left)
////////////// code snippets
////////////////////////////////////////////////////////////
I create the following during my main forms create event
FUserData := TUserDataFunc.Create;
FUserData.OnConCount := ChangeConnectionCount;
RequestBroker1.UserData := LongInt(FUserData);
The server object is declared as (in a seperate pas file from the main
form)
type
TServerObjectCONECT_SERVER = class(TServerObject)
private
protected
public
FUserData: TUserDataFunc;
procedure Execute; override;
published
end;
The TUserDataFunc object is declared as (again in a seperate pas file
from the main form)
type
TUserDataFunc = class(TObject)
private
FOnConCount: TChangeCountEvent;
protected
procedure AllowUserConnection(CntAdrr: Integer);
public
UserList: TList;
.... etc etc
end;
The first couple of lines of the excute procedure
procedure TServerObjectConect_Server.Execute;
var
LocUData: TUserDataFunc;
begin
FResultStatus := EC_10_Int;
if not Assigned(FUserData) then raise Exception.Create('FUserData not
assigned');
LocUData := TObject(FUserData) as TUserDataFunc;
if not Assigned(LocUData) then raise Exception.Create('LocUData not
assigned');
More information about the Delphi
mailing list