EAccessViolation when using SDAC over runtime package boundaries

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tgvoelker
Posts: 1
Joined: Mon 24 Sep 2018 07:26

EAccessViolation when using SDAC over runtime package boundaries

Post by tgvoelker » Mon 24 Sep 2018 08:26

The package contains one form:
unit Unit3;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, DBAccess, MSAccess, Vcl.Grids,
Vcl.DBGrids;

type
TForm3 = class(TForm)
DBGrid1: TDBGrid;
MSDataSource1: TMSDataSource;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure ShowIt(DS:TDataset);
end;

var
Form3: TForm3;

procedure ShowForm(DS:TDataset);

exports
ShowForm;

implementation

{$R *.dfm}

procedure TForm3.ShowIt(DS:TDataset);
begin
MSDataSource1.DataSet:=DS;
ShowModal;
end;

procedure ShowForm(DS:TDataset);
Begin
Form3:=TForm3.Create(nil);
try
Form3.ShowIt(DS);
finally
FreeAndNil(Form3);
end;
End;

end.
Tho calling module also:
unit Unit4;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB, MemDS, DBAccess,
MSAccess;

type
TForm4 = class(TForm)
Button1: TButton;
MSConnection1: TMSConnection;
MSTable1: TMSTable;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

TDSProc = procedure(DS:TDataset);

var
Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.Button1Click(Sender: TObject);
var h:THandle;
p:TDSProc;
begin
H:= LoadPackage('D:\TEMP\20180923 -- BPL-Test\Package1250.bpl');
try
if (H <> 0) then
begin
@P := GetProcAddress(H, 'ShowForm');
if Assigned(P) then
P(MSTable1);
end;
finally
UnloadPackage(H);
end;
end;

procedure TForm4.Button2Click(Sender: TObject);
begin
MSTable1.Active:=False;
MSTable1.Connection:=nil;
MSConnection1.Connected:=False;

Close;

end;

end.
After Closing the EAccessViolation Error is dropped if the MSTable is assigned to the MSDatasource. If it isn't, there is no error. Even changing ShowIt-proc to
procedure TForm3.ShowIt(DS:TDataset);
begin
MSDataSource1.DataSet:=DS;
ShowModal;
MSDataSource1.DataSet:=nil;
end;
Does not change this behaviour.

Please give me a short note how to prevent the EAccessError.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: EAccessViolation when using SDAC over runtime package boundaries

Post by Stellar » Tue 25 Sep 2018 11:50

Unfortunately, we can't reproduce the issue. To investigate this behavior of SDAC, please compose a small sample demonstrating the issue and send it to us, including database objects creating scripts. You can send the sample using the contact form at our site: devart.com/company/contactform.html

Post Reply