Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataSnap Server Methods - Marshalling nesting objects

I have a datasnap client / server in Delphi XE6

I am receiving an invalid pointer operation in the following server method call on the client side.

S := ClientModule1.ServerMethods1Client.getReport(RunReportObj,
        ReturnFileSize);

when I debug (step into), it sees the error is within a nested object of the TRunReportObj I am passing to the server method

 TRunReportObject
 private
  ...
  fCriteria: TCriteriaList;
  ...
public
  function AddCrit(Const aField, aOperation: String; Const aValues: TStrings): TCriteriaObject; 
  property CritObjects[index: Integer]: TCriteriaObject read GetCritObject;
  property Criteria: TCriteriaList read fCriteria write fCriteria;
...
end;

TCriteriaList is TObjectList

TCriteriaObject = class(TJSONParamObject)
  private
    fField: String;
    fOperation: String;
    fValues: TStringList;
    function GetJSONObject: TJSONObject; override;
  public
    property Field: String read fField write fField;
    property Operation: String read fOperation write fOperation;
    property Values: TStringList read fValues write fValues;
    constructor create;
    destructor destroy;override;
  end;

if I change fValues: TStringList to a string, it works fine

So, the issue is with the stringlist property "Values" which i have made sure it is created and destroyed

constructor TCriteriaObject.create;
begin
  inherited Create;
  fValues := TStringList.create;
end;

destructor TCriteriaObject.destroy;
begin
  fValues.Free;
  inherited destroy;
end;

I think there may be a marshalling issue??? Can anyone confirm this?

like image 775
John Avatar asked Dec 06 '25 21:12

John


1 Answers

I have had similar problems in Delphi XE6. I had to convert any TStringList to String.

In your case :-

fValues : String;

Property Values : String read GetValues write SetValues;

In the routines GetValues and SetValues you need to convert to and from the string.

like image 150
Peter G Evans Avatar answered Dec 11 '25 16:12

Peter G Evans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!