LocalReport.ExecuteReportInCurrentAppDomain-Methode
Hinweis: Diese API ist mittlerweile veraltet.
Verursacht Verarbeitungserweiterungen und -ausdrücke im Bericht, der in der aktuellen AppDomain ausgeführt werden soll.
Namespace: Microsoft.Reporting.WinForms
Assembly: Microsoft.ReportViewer.WinForms (in Microsoft.ReportViewer.WinForms.dll)
Syntax
'Declaration
<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
)
Parameter
- reportEvidence
Typ: Evidence
Ein Evidence-Objekt, das Sicherheitsinformationen zum Bericht enthält.
Hinweise
Wichtig
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 Kompatibilität und Migration von Richtlinien für die Codezugriffssicherheit.
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.
Beispiele
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");