在cSwitchSchemeService.pas中定义了
unit cSwitchSchemeService;{$I 'VersionControlOption.inc'}interfaceuses
uSwitchConsts, cBTSInfo, cSwitchSchemeInfo, cSwitchSchemeDao, cNEBasicSrv,
Classes, DB, DBClient;type
TSwitchSchemeService = class(TNEBasicSRV)
private
FSchemeDAO: TSwitchSchemeDao;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
public
function UpdateToSwitchScheme(): Boolean;
end;
然后在cMonitorService.pas中调用UpdateToSwitchScheme函数
unit cMonitorService;{$I 'VersionControlOption.inc'}interfaceuses
uCMUnifyGlobal, uSouthConsts, cDeviceInfo, uPubCtls, uParamCtls,
DBClient,cSwitchSchemeService;type
TMonitorService = class
private
protected
FSwitchSchemeSrv: TSwitchSchemeService;
public
constructor Create;
destructor Destroy; override;
function MonitorSrv: TMonitorService;
end;implementation
........
if FSwitchSchemeSrv = nil then FSwitchSchemeSrv.Create;
FSwitchSchemeSrv.UpdateToSwitchScheme;
........
结果程序运行期间到调用这个函数时就出现了Access violation at address的错误,是我调用的方式不对吗?还是什么原因,新手,望各位大侠多指教
unit cSwitchSchemeService;{$I 'VersionControlOption.inc'}interfaceuses
uSwitchConsts, cBTSInfo, cSwitchSchemeInfo, cSwitchSchemeDao, cNEBasicSrv,
Classes, DB, DBClient;type
TSwitchSchemeService = class(TNEBasicSRV)
private
FSchemeDAO: TSwitchSchemeDao;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
public
function UpdateToSwitchScheme(): Boolean;
end;
然后在cMonitorService.pas中调用UpdateToSwitchScheme函数
unit cMonitorService;{$I 'VersionControlOption.inc'}interfaceuses
uCMUnifyGlobal, uSouthConsts, cDeviceInfo, uPubCtls, uParamCtls,
DBClient,cSwitchSchemeService;type
TMonitorService = class
private
protected
FSwitchSchemeSrv: TSwitchSchemeService;
public
constructor Create;
destructor Destroy; override;
function MonitorSrv: TMonitorService;
end;implementation
........
if FSwitchSchemeSrv = nil then FSwitchSchemeSrv.Create;
FSwitchSchemeSrv.UpdateToSwitchScheme;
........
结果程序运行期间到调用这个函数时就出现了Access violation at address的错误,是我调用的方式不对吗?还是什么原因,新手,望各位大侠多指教
TSwitchSchemeService = class(TNEBasicSRV)
private
FSchemeDAO: TSwitchSchemeDao;
public
constructor Create(AOwner: TComponent); override;//这里不是有个参数么??
if FSwitchSchemeSrv = nil then FSwitchSchemeSrv.Create;//你这里没有参数?
if FSwitchSchemeSrv = nil then FSwitchSchemeSrv.Create;//你这里没有参数?
我的意思是你这里有个参数Owner: TComponent,但你创建时并没有传值进去。
2.有可能是你UpdateToSwitchScheme里面调用了为NIL的参数。