2010的ReportViewer未评估前pressionsReportViewer、pressions

2023-09-03 13:32:23 作者:开只佛手抢银行.

我的项目是在4.0框架ASP.Net WebForms的,使用的ReportViewer 10,使用本地处理模式呈现的地方RDLC报告。

My project is ASP.Net WebForms on 4.0 framework, using the ReportViewer 10, local RDLC reports rendered using Local processing mode.

我的问题是,许多前pressions在我的报告没有评估。例如,我在报告中以 =全局简单的EX pression页脚文本框的PageNumber ! - 但报告运行时,我只是得到#在这一领域的错误。我得到一个类似#错误只是在做一个toString我的领域之一 - ! =字段MyBooleanField.Value.ToString()

My problem is that many of the expressions in my report are not evaluating. For example, I have a textbox in the footer of the report with the simple expression of =Globals!PageNumber - but when the report runs, i just get #Error in that field. I get a similar #Error just doing a ToString on one of my fields - =Fields!MyBooleanField.Value.ToString().

此外,在我的页脚, = DateTime.Now 不工作,而 =全局!ExecutionTime 不起作用。

Also in my footer, =DateTime.Now DOES work, while =Globals!ExecutionTime does NOT work.

这是没有意义的我 - 就好像我失去了一个参考什么的。我在我的项目既Microsoft.ReportViewer.Common(V10)和Microsoft.ReportViewer.WebForms(V10)引用。

This makes no sense to me - it's as if I'm missing a reference or something. I have references in my project to both Microsoft.ReportViewer.Common (v10) and Microsoft.ReportViewer.WebForms (v10).

任何人有任何建议,我错过了什么,或者我怎么能得到这个解决了吗?

Anyone have any suggestions as to what I'm missing, or how I can get this resolved?

推荐答案

我看到三个选项:

选项1:抬高沙箱权限

防爆pressions被编译成一个单独的程序,并与较少的权限的沙箱中运行。使用它可以提高给沙盒的权限。有可能是一个较小的权限设置可以授予,我们只是没有花摸不着头脑的时候。这将意味着,报告和它引用会有提升权限的任何组件。该解决方案为我们工作(MVC 3,.NET 4中,VS2010,Microsoft.Reporting V10),虽然我们还没有部署到生产呢。

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());

选项2:构建上的.Net 3.5框架

的.Net 3.5下编译您的项目

Compile your project under .Net 3.5

方法3:legacyCasModel

添加到您的web.config:

Add this to your web.config:

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

这prevents您使用动态变量(在某些或所有情况下?)。特别是,Asp.Net MVC 3不能使用,因为ViewBag是动态的。

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.

更多信息

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/ex$p$pssion-evaluation-in-local-mode.aspx