#1 2023-02-09 03:55:56

guxinglei
Member
Registered: 2018-04-23
Posts: 5

"Access violation" error debugging

var
  LineArray,LineJson:TDocVariantData;
  VarJson:Variant;

......
LineArray.Init;
LineJson.Init;
......
{
TDocVariantData(VarJson).InitJSON(LineJson.ToJSON());  //watch "VarJson":Access violation at 40021120 accessing 40021120
LineArray.AddItem(VarJson);
VarClear(VarJson);
}
LineArray.AddItem(Variant(LineJson)); //convert to Variant watch "LineArray": (275, [dvoIsArray], (), (Access violation at 40021120 accessing 40021120, Access violation at 40021120 accessing 40021120, Unassigned, Unassigned), 2)
LineJson.Clear;
......

IDE:Build with runtime packages

Last edited by guxinglei (2023-02-09 04:13:37)

Offline

#2 2023-02-09 07:54:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: "Access violation" error debugging

Your code is not enough to reproduce the issue.

First try without runtime packages.

Then see what is inside VarJson.
TDocVariantData(VarJson) is not correct to initialize a variant: you need to use VarJson := _Json Fast(LineJson.ToJson));

Offline

#3 2023-02-09 09:20:11

guxinglei
Member
Registered: 2018-04-23
Posts: 5

Re: "Access violation" error debugging

without runtime packages is ok,why!

Offline

Board footer

Powered by FluxBB