Problem on Serialization

I’ve just had to build new VM for a Delphi 10.4 application - probably the first time I have had to touch it in a couple of years. I have installed the latest RO but now get an error when I call

procedure ObjectToStream(anObject: TROComplexType; Dest: TStream);

The error is in

TROStreamSerializer.WriteLegacyString

The error is

Cannot write string with length 15. Max allowed length is 0

Any ideas? Thanks

Hi,

Check Message.MaxStringSize property. it should have -1 value by default. in your case seems it has 0 value.

The TROStreamSerializer.MaxSizeString does have a value of 0. However, I can’t see where this is set.

Hi,

default value is set in

procedure TROMessage.InitObject;
begin
  fMaxStringSize := -1;

value in serializer is set in

function TROMessage.GetSerializer: TROSerializer;
begin
  Result := fSerializer;
  fSerializer.MaxStringSize := fMaxStringSize;
end;

Hi,

this was fixed for next build.
you can change all entries of (MaxStringSize <> 0) with (MaxStringSize > 0) in ROD code.

1 Like

Thanks @EvgenyK .

FYI, the procedure I am using is the standalone ObjectToStream(anObject: TROComplexType; Dest: TStream) and StreamToObject in uROSerializer. This creates a TROStreamSerializer but doesn’t set the MaxStringSize. In turn this eventually calls TROStreamSerializer.WriteLegacyString which tests for (MaxStringSize <> -1).

As it’s marked as Default perhaps it should be set in the Create method?

Hi,

Thanks for detecting this issue.
I’ve already changed code so it checks for (MaxStringSize > 0).
This issue should be fixed for next build

Hi,

sure, will set it in constructor for TROSerializer

new build (.1549) was released

1 Like