Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expression_Host assemblies keep growing in numbers

I have a WinForms 2.0 application with about 18 Reports created with Microsoft ReportViewer. Every time a report is started there is a dynamic assembly created (expression_host_xxxxxx.dll). This dynamic assembly is loaded in memory and is there to stay for the remainder of the application runtime consuming resources. Even if we only have 1 report and we start this ie 3 times, we get 3 such expression_host assemblies in memory.

Is there a way to prevent these assemblies from being created or to unload these assemblies after we are done?

TIA

like image 549
Huberto Avatar asked Jul 20 '09 09:07

Huberto


1 Answers

I already found a solution. On the reportviewer control you can signify to execute the report in an so-called sandbox app-domain:

`rpv1.LocalReport.ExecuteReportInSandboxAppDomain();`

This will not prevent the creation of the Expression_Host assemblies because these are necessary to evaluate the expressions you have used in your report. It will however start the report in a new application domain. That new application domain is then unloaded after the report is finished and as a result, any loaded assembly in that domain is also unloaded.

like image 87
Huberto Avatar answered Nov 01 '22 18:11

Huberto