LocalReport.AddTrustedCodeModuleInCurrentAppDomain 方法

Adds the supplied assembly to the list of assemblies that are trusted to execute in the current AppDomain.

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

语法

声明
用法

参数

  • assemblyName
    The name of the assembly to be added.

备注

Expressions in the report will be executed in the current AppDomain with only the Execution security permission flag. By default, custom assemblies are not allowed in this mode. The AddTrustedCodeModuleInCurrentAppDomain method can be used to allow the use of custom assemblies in the current AppDomain.

The name of the assembly passed in the assemblyName parameter should match that specified in the CodeModule element of the report definition file.

示例

In this example, a custom assembly containing a simple utility function that calculates factorials is used as an expression in a report.

using System.IO;
using System.Reflection;

public class Util
{
    public static int Factorial(int n)
    {
        return ((n <= 1) ? 1 : (n * Factorial(n - 1))); 
    }
}

The following code is used to add the custom assembly to the current AppDomain.

reportViewer.LocalReport.ReportPath = "Report1.rdlc";

reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(
   "Contoso.Utilities, 
   Version=1.0.271.0, Culture=neutral,
   PublicKeyToken=89012dab8080cc90");

For more information on custom assemblies, see "Using Custom Assemblies with Reports" in the SQL Server Books Online.

另请参见

参考

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