Partager via


LocalReport.ExecuteReportInCurrentAppDomain, méthode

Remarque : cette API est maintenant obsolète.

Entraîne l'exécution, dans le AppDomain actuel, des extensions et des expressions de traitement présentes dans le rapport.

Espace de noms :  Microsoft.Reporting.WebForms
Assembly :  Microsoft.ReportViewer.WebForms (dans Microsoft.ReportViewer.WebForms.dll)

Syntaxe

'Déclaration
<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 _
)
[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
)
[ObsoleteAttribute(L"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
)
[<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 
public function ExecuteReportInCurrentAppDomain(
    reportEvidence : Evidence
)

Paramètres

  • reportEvidence
    Type : Evidence
    Objet Evidence contenant des informations sur la sécurité du rapport.

Notes

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 <NetFx40_LegacySecurityPolicy> configuration element in the Web.config file of your ASP.NET application.Otherwise, this method will throw an InvalidOperationException.

For more information, see Compatibilité de la stratégie de sécurité d'accès du code et 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.

Exemples

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

Voir aussi

Référence

LocalReport Classe

Microsoft.Reporting.WebForms, espace de noms