Expression_Host Collections Continue to Grow

I have a WinForms 2.0 application with approximately 18 reports created using Microsoft ReportViewer. Every time a report starts, a dynamic assembly (expression_host_xxxxxx.dll) is created. This dynamic assembly is loaded into memory and stays for the remainder of the time using the application resources. Even if we only have 1 report, and we start it, i.e. 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 finish?

TIA

+6
c # winforms reportviewer
source share
1 answer

I have already found a solution. In the reportviewer control, you can specify the execution of the report in the so-called sandbox application area:

`rpv1.LocalReport.ExecuteReportInSandboxAppDomain();` 

This does not prevent the creation of Expression_Host collections, as they are necessary to evaluate the expressions that you used in your report. However, it will run the report in the new application domain. Then this new application domain is unloaded after the report is completed and, as a result, any loaded assembly in this domain is also unloaded.

+4
source share

All Articles