LocalReport.ExecuteReportInCurrentAppDomain Method (Evidence)

 

Note: This API is now obsolete.

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

Namespace:   Microsoft.Reporting.WinForms
Assembly:  Microsoft.ReportViewer.WinForms (in Microsoft.ReportViewer.WinForms.dll)

Syntax

[ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated.  For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")]
public void ExecuteReportInCurrentAppDomain(
    Evidence reportEvidence
)
public:
[ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated.  For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")]
void ExecuteReportInCurrentAppDomain(
    Evidence^ reportEvidence
)
[<ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated.  For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")>]
member ExecuteReportInCurrentAppDomain : 
        reportEvidence:Evidence -> unit
<ObsoleteAttribute("This method requires Code Access Security policy, which is deprecated.  For more information please go to https://go.microsoft.com/fwlink/?LinkId=160787.")>
Public Sub ExecuteReportInCurrentAppDomain (
    reportEvidence As Evidence
)

Parameters

Remarks

Important

This method is deprecated for .NET Framework 4 because the code access security (CAS) feature it relies on is deprecated in .NET Framework 4. Instead, the ReportViewer control always executes in the sandboxed application domain. You should use AddFullTrustModuleInSandboxAppDomain and SetBasePermissionsForSandboxAppDomain. If you want to continue to use this method with .NET Framework 4, you must use the in the Web.config file of your ASP.NET application. Otherwise, this method will throw an InvalidOperationException.

For more information, see Code Access Security Policy Compatibility and Migration.

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. In .NET Framework 3.5, this is the default mode and is the mode to use for trusted reports. See the table below for the default application domain modes in different .NET Framework versions.

.NET Framework Version

LegacySecurityPolicy Enabled?

Default Application Domain

Useable Application Domain Modes

4

No (Default)

Sandboxed

Sandboxed

4

Yes

Current

Sandboxed and current

3.5

N/A

Current

Sandboxed and current

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.

Examples

Legacy Code Example

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 run 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");

See Also

LocalReport Class
Microsoft.Reporting.WinForms Namespace

Return to top