Failed to load expression host assembly. SecurityPermission ReportViewer 9.0.0.0

Joined
Oct 8, 2009
Messages
2
Reaction score
0
I am involved in the development of an ASP.NET web application that uses pass-through Windows authentication. This application provides users with a number of reports, developed with the Visual Studio 2008 report designer and deployed in Local mode via the Microsoft ReportViewer version 9.0.0.0 (2008 Redistributable) component.

This application works fine in my development environment, and also on the dev environment provided by our client. However, the application failed to work on a pre-production environment. More specifically, 3 out of the 4 available reports fail to load and result in the following message being displayed by the ReportViewer component:

Code:
Failed to load expression host assembly. Details: Request for the permission
of type 'System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

The ReportViewer assemblies (Common, WebForms, ProcessingObjectModel etc.) are all registered in the GAC (both versions 9.0.0.0 and 8.0.0.0 on the pre-prod machine)

The reports are invoked by first constructing a datasource programmatically using a TableAdapter followed with some filtering. Next, the datasource and report parameters are assigned, followed by an invocation to "RefreshReport " to display the report.

I have tried an alternative suggested on the net, by replacing the method above by the method: ExecuteReportInCurrentAppDomain . This however resulted in an AccessViolationException .

The odd aspect of all this is that one of the 4 reports works fine, which seems to eliminate a purely environmental issue. The only apparent difference between the working report and the failing ones is that it does not use the built-in report parameters functionality.

Can anyone please suggest a solution to the above?
Thanks,
Colin
 
Last edited:
Joined
Oct 8, 2009
Messages
2
Reaction score
0
Found a solution (of sorts)

I eventually found a solution to this, or rather, a workaround:

I have verified that the problem occurs for reports that use report parameters. This seems to trigger the creation of an expression host assembly in memory.. I'm not sure. Anyhow, I passed the required parameters (which I only needed for display anyway) as additional columns in the report's data source. The field values are repeated throughout all the rows in the data set. Hence, to display the parameters I simply define text box controls using the First() function to populate the values. The drawback is that parameters cannot be displayed in the report header, and hence cannot be repeated for each and every page of the report. This is usually not a problem and in general it is desirable not to repeat parameters in the page headers as these waste valuable page space and therefore paper.

I hope you find this workaround useful.. thought it was worth sharing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top