This is a migrated thread and some comments may be shown as answers.

Dynamically Adding New Reports?

2 Answers 136 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 16 Nov 2012, 05:02 PM
Is there a way to dynamically instantiate the proper report class and add it to the ReportViewer? For example I have a pre-existing DLL with a single report class in it. Now I add a second report class to that same DLL and replace it on my web server. Let's say I want to use my database to store the names of the report classes, so I can easily add an entry and have it immediately added to a dropdown list. And when I select from the list it will reload an iFrame that has my ReportViewer in it (I actually already have this reloading piece), but is there a way I can code that ReportViewer page to instantiate the class name I have passed to it?

Basically I want to be able to create a new report and just drop the updated DLL onto my server, and with a quick database change have access to the report (i.e. without having to code anything into my report selection or report viewer pages, and possible re-compile etc.)

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 19 Nov 2012, 12:37 PM
Hi John,

When you dynamically add assemblies in order to avoid recompilation you should load the report assemblies with reflection. For this you can use the Assembly.Load Method. Once the assembly is loaded in the app domain you can resolve any Telerik Reporting types as we have done in our demo ReportManager class. The ReportManager is available as part of the demos that came with your Telerik Reporting installation. When the target report type is selected you can instantiate it with Activator.CreateInstance Method.

Still if applicable the straightforward solution is to serialize the reports in XML or create them with the Report Designer. The XML reports are easier to manage as they don't need compilation and are version agnostic. If you want to give it a try check out the following help articles:
Greetings,
Peter
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Xorcist
Top achievements
Rank 1
answered on 19 Nov 2012, 02:19 PM
Do you have any examples of using the Activator.CreateInstance Method to dynamically load a report? I couldn't find any examples in the demos supplied with the latest Reporting 2012 install. I attempted to use the CreateInstance method myself, but haven't quite got it working.

EDIT: Oops, looks like I need to use a qaulifed assembly name, I wasn't. It's working now. Thanks.
Tags
General Discussions
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Peter
Telerik team
Xorcist
Top achievements
Rank 1
Share this question
or