- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I started a project of an add-in for Revit which should take some parameters (values from Revit elements) and show them in a Report (a Report RDLC) and then be able to print the report. I developed the project in Visual Studio 2017 on .Net Framework 4.7.2 starting with the “Revit 2019 Addin” from The Building Coder. I added the NuGet Package Microsoft.ReportingServices.reportViewerControl.Winforms (and the package Microsft.SqlServer.Types that comes with it). I then added a Report.rdlc and a form with a report viewer on it. I first added a simple text to the report and tried to run the add-in in Revit 2019 and it worked fine (showing the report). I then added some parameters to the report and here start the problems L, the report shows an error :
“An error occurred during local report processing. Failed to load expression host assembly. Details: Impossible to load the file or the assembly ‘Microsoft.ReportViewer.Common, Version 15.0.0.0, Culture=neutral, PublicKey Token= 89845dcd8080cc91’…”
After searching around in the web, it seems that this is a problem with security policies related to ReportViewer. I also tried to add these three lines of code (which I found on a blog and were solving the problem by a couple of users) in the load method of the form that contains the ReportViewer:
this.reportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence);
PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
this.reportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(permissions);
But unsuccessfully… it still doesn’t work and now it is showing a message box with this error:
“Report execution in the current AppDomain requires Code Access Security policy, which is off by default in .NET 4.0 and later. Enable legacy CAS policy or execute the report in the sandbox AppDomain”.
I have to add, that I’m not very experienced with programming and the Revit API, but I really would like this project to work….
Your help will be very much appreciated! THX
Solved! Go to Solution.