TfrReport.PrepareReport: EInvalidCastException
I have just upgraded from 2.5 to 2.51. I have the fr.inc file set to BDE, and am using the InfoPower IBO components to connect through IBO to an Interbase database.
When I call:
report.LoadFromFile ('filename.frf');
report.PrepareReport;
I get an EInvalidCastException on the line report.PrepareReport.
Anyone know what may be wrong? (Everything was working fine using 2.5!)
Loryn Jenkins
When I call:
report.LoadFromFile ('filename.frf');
report.PrepareReport;
I get an EInvalidCastException on the line report.PrepareReport.
Anyone know what may be wrong? (Everything was working fine using 2.5!)
Loryn Jenkins
Comments
or if in d7 turn off invalid cast warning?
Is there more to the message?
does it happen running in ide or outside in compiled exe?
Many possibilities, and most of us can't read your mind, so supply as much info as you can.
regards
Anway, for the sake of documenting the issue, here is what was occurring:
When I ran the code from within the debugger, I would get this message:
Debugger Exception Notification
Project Test.exe raised exception class EInvalidCast with message 'Invalid class typecast'. Process stopped. Use Step or Run to continue.
The breakpoint was set on this line:
class FR_Class
procedure CreateDS
...
DataSet := frFindComponent(CurReport.Owner, Desc) as TfrDataSet;
And when tracing it down the call stack, the actual exception was being thrown on this line:
class FR_Utils
procedure FrFindComponent
...
Result := Owner.FindComponent(Name)
Now, the type of the component was a TwwDataSource. I was linking my TfrDBDataSet to the TwwDataSource rather than directly linking it to the TwwIBOQuery.