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

Unable to Preview a Report that Uses EntityDataSource

3 Answers 51 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 03 Aug 2017, 03:24 PM

Hi,

I have a report that is using an EntityDataSource to access data from an EntityFramework context in a separate assembly. When I try to view this report in preview, I see the following message in the Preview tab: "Exception has been thrown by the target of an invocation. Could not load type '<My EF Context Type>' from assembly '<My EF Context Assembly>" This appears to be all the help I get with this issue. How can I move forward? Is there any form of logging that I can access etc. etc? I have subscribed to the report's Error event but that isn't fired.

By the way: I have also written a console application that instantiates the report and exports it to PDF using the ReportProcessor. This works just fine so I know the issue isn't a simple missing reference or similar. Clearly, the report preview functionality has some extra requirements that I am not fulfilling.

Windows 7 64-bit, VSTS 2017 targeting .NET 4.5, Telerik Reporting 11.1.17.614.

NB:

  • My context has a constructor that accepts a connection string and when run through the console app, a break point reveals a correct connection string going in and being passed to the base EF context class.
  • I have added the assembly that defines my EF context into the Telerik section of the Telerik report assembly's app.config, in the <assemblyReferences> section.
  • My EF context is database first.
  • The assembly (project) that defines the report references EF, EF,SqlServer and my own assembly that defines my EF context.

 

I'm not sure what else you will need so I'll leave it like this for now. Let me know if you need anything else.

Thanks

 

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 04 Aug 2017, 01:39 PM
Hello Mark,

If the EF model is built in an external assembly and loaded in VS Report Designer, the assembly might be locked and loaded multiple times, which can lead to conflicts on loading the data in the Visual Studio Report Designer Preview and the data source wizard. To work around this issue you can try extending the Standalone Report Designer to load the external assembly and then preview should be working correctly. Also, you can display the report in a viewer (e.g. WinForms viewer) just for the purpose of previewing it.

This issue is logged in our system for improvement, but we are still struggling to implement a fix. This is due to the fact that the Visual Studio Report Designer works in the context of Visual Studio and we depend on it as well. When you preview a report the project is rebuilt and the assemblies are loaded in the app domain of Visual Studio. Then Telerik Reporting instantiates the objects needed for the report and finally, the report is processed and rendered.
When using Entity Framework for your reports those assemblies have to be loaded too so that the wizard can discover all types suitable for EntityDataSource, for populating the fields and for previewing the report. However, all this still happens in the context of Visual Studio. On the other hand, VS uses Entity Framework for its internal workings from version 2012 and up. What this means is that when the Report Designer with EF is used VS loads the EF assemblies twice. Because of that, the service that is responsible for retrieving the correct types in the context of VS has trouble retrieving generic classes. While the generic type definition will be loaded from one assembly the generic type argument can be loaded from the other assembly thus causing the constraint violation (since it is from another assembly the respective type is not the same as the generic type parameter).

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 04 Aug 2017, 01:48 PM

OK Nasko, thanks for the reply. It sounds like a nightmare. Unfortunately, without it, the VS report designer is basically useless for (pie) charts. I have managed to design tabular reports and then test them with my console application but so far, I have been unable even to produce the simple pie chart. Perhaps it's just that I haven't made that leap in understanding yet.

I am interested in the idea of extending the standalone report designer but haven't had a chance to review the link yet. One question though: I seem to remember that reports developed in the standalone designer are fundamentally different to those in the VS designer. Is this the case? Do I have to make a firm decision regarding where and how I edit my reports, or can I start in one designer and then move to another and vice-versa? I ask because I *greatly* prefer to work in VS.

0
Katia
Telerik team
answered on 09 Aug 2017, 09:00 AM
Hi Mark,

Standalone Designer is a desktop tool that has the same functionalities as VS Designer. Reports produced by this designer are packaged XML definition and resources (TRDP format) and plain XML (TRDX format).

You can convert reports created in Standalone Designer into Visual Studio Designer and vice versa:

Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Mark
Top achievements
Rank 1
Katia
Telerik team
Share this question
or