任何人都知道我为何会通过以下获取访问权限:
unit TestForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Generics.Collections, Vcl.Grids,
Vcl.ValEdit;
type
TClientThing = class
private
iCDic: TDictionary<string, string>;
published
property Dic: TDictionary<string, string> read iCDic write iCDic;
end;
TForm1 = class(TForm)
vleHeader: TValueListEditor;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
ClientThing: TClientThing;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
vCustomParamKey: string;
vCustomValueKey: string;
J: integer;
begin
with ClientThing do
begin
// Get the header params from the config and list edit...
for J := 0 to vleHeader.RowCount - 1 do
begin
vCustomParamKey := vleHeader.Cells[0, J];
vCustomValueKey := vleHeader.Cells[1, J];
Dic.Add(vCustomParamKey, vCustomValueKey);
end;
end;
end;
end.
访问冲突位于Dic.Add行。例外是:
我整晚都在上班,所以可能错过了什么。 TValueListEditor内容是(代码编辑器视图):
X-Application=g9V0rB9a3J5UF8
X-Authentication=kQNvuuimr0yMtEYZtXAZntTScPlvjecEAGtvbnNIU=
JSONRpc=2.0
答案 0 :(得分:4)
表单永远不会为ClientThing
分配值,因此它仍为nil
。为其分配值,然后为iCDic
分配值。当您使用调试器逐步执行代码时,您应该能够检测到此问题。