Reputation: 1468
With RttiContext.FindType('Classes.TStringList')
I get RttiType of TStringList with no problem. But with RttiContext.FindType('MyUnit.TMyClass')
I always get nil (of course MyUnit is in uses clause). Why, what is wrong?
Example:
unit MyUnit;
interface
uses
Classes;
type
TMyClass = class(TStringList)
end;
implementation
end.
Main unit:
...
uses
MyUnit,
...
var
oCont: TRttiContext;
oType: TRttiType;
begin
oCont := TRttiContext.Create;
try
oType := oCont.FindType('MyUnit.TMyClass'); <== oType = nil !!
...
Upvotes: 4
Views: 2873
Reputation: 1784
Probably the class has not included by the delphi linker in the final executable. A fast try can be the following:
begin end
. TRttiContext.FindType
. Upvotes: 9
Reputation: 84650
It could be a handful of things. Hard to say without seeing your code, but here are a few suggestions to look at. Is TMyClass a public type in the interface section? Is RTTI generation turned on for that unit? Is MyUnit in a package that hasn't been loaded yet?
Upvotes: 1