I came across the above stated error while the report being rendered in Windows forms application with the results printed as “#Error”. The data source used is Object data source whose assembly is different than the report’s (rdlc) assembly.
The error output from the debug window is shown below.
The following points worth mentioning for this cause:
- The Object’s used to design the report (data source) is in a different assembly than the report’s (rdlc) assembly.
- parameters are used to print custom information in the report
- Custom code (proprietary vs.net report specific code hosted in the report itself which can be found in the report properties->code tab) was used in the report to overcome null values
- In the Security’s tab under the main winform’s start up project’s properties’ following are checked (refer the diagram)
- Enable the ClickOnce Security Settings
- This is a full trust application
From the error message it is clear that the issue is due to security but how to overcome? can we change the security settings as “This is a partial trust application” instead full trust?. We can but in our case I can’t change which will impact globally.
What we did was, we added the following code to allow partially trusted callers in the AssemblyInfo.vb for the project where our domain objects (Object data source) reside
In our reports, we used custom codes, expressions etc which needs to be compiled and executed at runtime through .Net reflection. Under Full trust, reflection will not work. Hope this helps!