Dear Stackoverflow users. I am in dire need for help. I have been struggling with the embedded in the Embarcadero XE2 RAD studio edition of FastReport 4.0. and more specifically I have been getting the same error, over and over again, which is the misterious "Class TfrxReport Not found" error. Below I submit a part of the code that causes the problems
procedure TForm1.buildReport(Sender: TObject);
var
DevicePic, SymbolPic: TfrxPictureView;
TitleEntry, xmlField: TfrxMemoView;
MasterDataBand: TfrxMasterData;
begin
if not ADOConnection1.Connected then
ShowMessage('Cannot build Report! Please, connect to the DB!')
else
try
//this is where the Class Not Found Exception is Thrown
frxReport1.LoadFromFile('LibreportTemplate.fr3',True);
// frxReport1.LoadFromFile('helloInfineonThree.fr3',True);
if (frxDBDataset1 = nil) then frxDBDataset1 := TfrxDBDataset.Create(Self);
// connect the report to the DATA
frxDBDataset1.DataSource := DataSource1;
frxReport1.DataSet := frxDBDataset1;
except
ShowMessage('Error has Occured! Report Template File Not Found!');
// exit from this procedure!
Exit;
end;
// If no errors have occured, go on building ur report by actually filling it up with data!
// attach dataSet to the masterdata band of the report.
MasterDataBand := frxReport1.FindObject('MasterData1') as TfrxMasterData;
MasterDataBand.DataSet := frxDBDataset1;
// prepare textfields
TitleEntry := frxReport1.FindObject('TitleEntry') as TfrxMemoView;
TitleEntry.DataSet := frxDBDataset1;
TitleEntry.DataField := 'LibFName';
xmlField := frxReport1.FindObject('xmlField') as TfrxMemoView;
// stretch the field if text too big.
xmlField.StretchMode := TfrxStretchMode.smActualHeight;
//get the XML DATA FROM THE DB.
xmlField.DataSet := frxDBDataset1;
xmlField.DataField := 'LibFXML';
// prepare images
DevicePic := frxReport1.FindObject('ImageEntry') as TfrxPictureView;
DevicePic.DataSet := frxDBDataset1;
DevicePic.DataField := 'LIBFIMAGE';
SymbolPic := frxReport1.FindObject('SymbolEntry') as TfrxPictureView;
SymbolPic.DataSet := frxDBDataset1;
SymbolPic.DataField := 'LibFSymbol';
// build and display report
frxReport1.PrepareReport();
frxReport1.ShowPreparedReport;
end;
When building and running the program, I get the following error message "Cannot Find class TfrxReport" and in DebugMode I get the following warning:
Project "MyProject.exe" raised exception class EClassNotFound with message 'Class TfrxReport not Found'.
As commented in the code above, the exception in question is thrown when executing the frxReport1.LoadFromFile('LibreportTemplate.fr3',True); command.
I tried many different approaches for solving the problem, including searching online for a solution. Here is what I did:
Manually create and destroy the frxReport1 object during Form OnCreate and OnClose - ERROR PERSISTS
As suggested in the FastReport ( I couldnt post the link on SO, cause of "Sorry, posts can't contain that content." error) forum thread, replace files in the FastReport 4\LibD16 folder. - ERROR PERSISTS
Recompile FastReport 4 RAD STUDIO 32 bit Version - ERROR PERSISTS Recompile FastReport 4 RAD STUDIO 64 bit Version - ERROR PERSISTS Reinstall Embarcadero RAD Studio and FastReport 4 - ERROR PERSISTS
ASK QUESTION IN STACKOVERFLOW - ????
From the thread in the fast-reports forum, it seems that the problem and the respective solution should be ( I QUOTE) :
This error causes by GroupDescendentsWith(TfrxReport, TControl); code. This code hides TfrxReport from FierMonkey and for some reason "FindClass" function can't find for TfrxReport class when you're loading report(only in IDE). If you can't load report or get similar error with "Couldn't find TfrxReport" message, put this "Link to Files" files to "Fast Report\LibD16" dir (replace all).
However the suggested approach DOES not Solve the problem! What should I do? Does anyone have any idea?
I've face this issue as well and I've solved it doing this,
You won't see results once design package is installed, I've restarted the IDE and it goes great ;)
With 2 years delay, I hope this could help!