Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:06:34+00:00 2026-06-07T07:06:34+00:00

Since two days ago I started making my own simple classes from scratch, descended

  • 0

Since two days ago I started making my own simple classes from scratch, descended from TObject, nothing fancy. I also needed to write/read them to/from files, so after some searching, because I haven’t yet learned all the ins and outs of serialization and don’t fully get them, I borrowed serialization methods from here. It worked fine as I was testing it. Then I added another class as a property (that’s what I’m referring to when I say sup-property: properties of a class that’s a property in my class… that’s confusing, it needs a proper name), following the advice in this SO question on how to actually do that. Now writing to file doesn’t seem to raise any errors, then again I’m not sure the sub-properties are written properly or it’s just garbage. Reading it back however does cause the

Exception class EPropertyConvertError with message ‘Invalid property type: TSomething’

Since I’m just learning this, I’m not sure what is wrong. I do have a few wild guesses, one of which would be that the TSomething = Class maybe has to have it’s own serialization methods? In that case how would that even work (cause even I don’t believe this assumption)? Another would be that the code I borrowed from delphi.about.com can’t handle these type of properties? And if so, how could I improve it? And if none of my guesses are correct, how would one make this work? (And I’m using DelphiXE2.)

Code as per request:

TSomething = Class
protected
  fNumber: integer;
  fLine: string;
public
  procedure Assign(Source: TObject);
published
  property Number: integer read fNumber write fNumber;
  property Line: string read fLine write fLine;
End;

TOther = Class
public
  procedure LoadFromStream(const Stream: TMemoryStream);
  procedure SaveToStream(const Stream: TMemoryStream);
  constructor Create; virtual;
  destructor Destroy; override;
protected
  fSomething: TSomething;
  procedure SetfSmth(AValue: TSomething);
published
  property Something: TSomething read fSomething write SetfSomething;
end;

The implementation for the methods has been borrowed from the two links that have been provided above, I see no need to retype that, unless asked for.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:06:38+00:00Added an answer on June 7, 2026 at 7:06 am

    To serialize TSomething, it must be a sub-component. To do that you have to change one thing: don’t derivate the two classes from TObject but rather from TComponent. Then in the TSomething constructor you call

    Self.SetSubComponent(True);
    

    FInally, as your class is a TComponent you won’t need anymore the stuffs grabed from delphi.about because a TComponent can be directly serialized in a TStream by using WriteComponent / ReadComponent

    You’ll see that the process is easyer when choosing the right descendant. Here the choice is logic: if you want to serialize then use TComponent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Major Edit based on experience since 1st post two days ago.] I am building
Since I updated two days ago my Android SDK to version API 14 I'm
I'm having a recent issue since two days ago. Before that I was running
I am trying since two days to install OpenCV 2.3.0 or 2.3.1 on my
I added two applications to my iTunes Connect account 10 days ago or so.
Since two days I am playing with C and I come across new problem
Since two days I am trying to consume a WCF (.NET) Soap Service and
I'm using Apache Maven3 and since two or three days some dependencies can't be
note: using django/python/javascript/flash So its been two days since I'm stuck at the error.
i am working on making my applications international. After two days digging on msdn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.