ReportViewer 2010 fails to evaluate expressions

和自甴很熟 提交于 2019-12-03 03:35:11

I've seen three options:

Option 1: Elevate sandbox permissions

Expressions are compiled into a separate assembly and run in a sandbox with fewer permissions. Use this to increase the permissions given to the sandbox. There is probably a smaller permission set you can grant, we just haven't spent the time to figure this out. This will mean the report and any assemblies it references will have elevated permissions. This solution is working for us (MVC 3, .Net 4, VS2010, Microsoft.Reporting v10) though we haven't deployed to production yet.

localReport.SetBasePermissionsForSandboxAppDomain(
    AppDomain.CurrentDomain.PermissionSet.Copy());

Option 2: Build on .Net 3.5 Framework

Compile your project under .Net 3.5

Option 3: legacyCasModel

Add this to your web.config:

<system.web>
  <trust legacyCasModel="true" level="Full"/>
</system.web>

This prevents you from using dynamic variables (in some or all cases?). In particular, Asp.Net MVC 3 cannot be used because the ViewBag is dynamic.

More information

http://social.msdn.microsoft.com/Forums/en-US/vsreportcontrols/thread/be1a6149-a120-4e66-96f8-63f5c4d43c87

http://blogs.msdn.com/b/brianhartman/archive/2010/02/18/expression-evaluation-in-local-mode.aspx

Prasad

The issue is due to some CAS policy changes in framework 4.0. Please add the following line in the web.config:

<trust legacyCasModel="true" level="Full"/>

in the <system.web> section

Refer link below:

http://blogs.msdn.com/b/brianhartman/archive/2010/02/18/expression-evaluation-in-local-mode.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!