Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Tools and Features
Microsoft Reports
Class Library
LocalReport Class
LocalReport Methods
 AddTrustedCodeModuleInCurrentAppDom...
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
LocalReport.AddTrustedCodeModuleInCurrentAppDomain Method

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

Namespace: Microsoft.Reporting.WinForms
Assembly: Microsoft.ReportViewer.WinForms (in microsoft.reportviewer.winforms.dll)
Visual Basic (Declaration)
Public Sub AddTrustedCodeModuleInCurrentAppDomain ( _
    assemblyName As String _
)
Visual Basic (Usage)
Dim instance As LocalReport
Dim assemblyName As String

instance.AddTrustedCodeModuleInCurrentAppDomain(assemblyName)
C#
public void AddTrustedCodeModuleInCurrentAppDomain (
    string assemblyName
)
C++
public:
void AddTrustedCodeModuleInCurrentAppDomain (
    String^ assemblyName
)
J#
public void AddTrustedCodeModuleInCurrentAppDomain (
    String assemblyName
)
JScript
public function AddTrustedCodeModuleInCurrentAppDomain (
    assemblyName : String
)

Parameters

assemblyName

The name of the assembly to be added.

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. The AddTrustedCodeModuleInCurrentAppDomain 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.

C#
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.

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

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

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

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker