LocalReport.ExecuteReportInCurrentAppDomain 方法

Causes processing extensions and expressions in the report to be executed in the current AppDomain.

命名空间: Microsoft.Reporting.WebForms
程序集: Microsoft.ReportViewer.WebForms (在 microsoft.reportviewer.webforms.dll 中)

语法

声明
用法

参数

  • reportEvidence
    An Evidence object containing security information about the report.

备注

Expressions in the report will be run in the current AppDomain with only the Execution security permission flag. By default, custom assemblies are not allowed in this mode. This is the default mode and is the mode to use for trusted reports.

This mode may also be used to run untrusted reports that do use trusted processing extensions.

To allow trusted processing extensions, the application must call AddTrustedCodeModuleInCurrentAppDomain.

示例

In this example, a custom assembly containing a simple utility function that reads some data from a text file is used as an expression in a report.

using System.IO;
using System.Reflection;

public class Util
{
    public static string GetData()
    {
        StreamReader sr = new StreamReader("data.txt");
        string data = sr.ReadToEnd();
        sr.Close();
        return data;
    }
}

The following code is used to allow the report with the custom assembly to execute in the current AppDomain.

reportViewer.LocalReport.ReportPath = "Report1.rdlc";
reportViewer.LocalReport.ExecuteReportInCurrentAppDomain(
      Assembly.GetExecutingAssembly().Evidence);
reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("Contoso.Utilities, 
      Version=1.0.271.0, Culture=neutral, PublicKeyToken=89012dab8080cc90");

另请参见

参考

LocalReport 类
LocalReport 成员
Microsoft.Reporting.WebForms 命名空间