Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sudden problem with RTTI

Status
Not open for further replies.

Griffyn

Programmer
Jul 11, 2002
1,077
AU
Hi all,

I've been using the routines from the TypInfo unit quite regularly, and all of a sudden it's thrown me by refusing to find the properties.

Code:
TBlahObject = class(TObject)
private
  FBlah : String;
published
  property Blah : String write FBlah;
end;

implementation

uses
  TypInfo;

var
  b : TBlahObject;
begin
  b := TBlahObject.Create;
  try
    SetStrProp(b, 'Blah', 'hello');  // Exception
  finally
    b.Free;
  end;
end;
This program by my reckoning should work no problem, but it doesn't, and raises an EPropertyError exception saying that the 'property Blah does not exist'. I'm stumped.

This is the simplest and shortest example to show what I'm trying, but I've tried other property names, reading, writing, integers, etc. None seem to work - yet the rest of my program that is using these routines succesfully, in seemingly exactly the same sort of way.

Help anyone?
 
dagnamit!

solved, but not without going a bit grey haired in the meantime. All my other classes I've been using with RTTI descended from a single class I set up, this one (and my example above do not) and because I've derived them from TObject - I needed to use the {$M+} compiler directive to force the compiler to generate RTTI information for the class, and it's descendents.

It's always something this simple.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top