access violation on clientmoduleunit.pas on client side

0

Well in my datasnap app on the client side i have obviously a clientmodule. I get an error on closing my application:

ERROR According to the debugger is in this funtion:

destructor TClientModule1.Destroy;
 begin
  FServerMethods1Client.Free;
  inherited;
 end;

compiller show this:

First chance exception at $0059ABC4. Exception class $C0000005 with message 'access violation at 0x0059abc4: read of address 0x00000034'. Process Cajero.exe (1856)

delphi
datasnap
asked on Stack Overflow May 9, 2015 by Caruso • edited May 9, 2015 by Caruso

1 Answer

0

According to you Screenshot you get an AV at a low adress $34 that indicates that you are caling methods on an object reference that is nil.

Try this dummy code

procedure TForm22.FormCreate(Sender: TObject);
begin
  TForm(nil).Next;
end;

And have a look at the adress at the AV.

When you try to call a method on a object, the compiler looks in a table called VMT to find trhe offset of the method. This value is added to the adress of the object reference.

In your code you have a property called ServerMethods1Client which is defined like this:

property ServerMethods1Client: TServerMethods1Client read GetServerMethods1Client write FServerMethods1Client;

Try change it to a readonly property

property ServerMethods1Client: TServerMethods1Client read GetServerMethods1Client;

Then the compiler will tell you where you are assiging a nil value to you property.

answered on Stack Overflow May 9, 2015 by Jens Borrisholt • edited May 9, 2015 by Jens Borrisholt

User contributions licensed under CC BY-SA 3.0