メモ: この API は、互換性のために残されています。
レポートの処理拡張機能と式が現在の AppDomain で実行されるようになります。
名前空間: Microsoft.Reporting.WebForms
アセンブリ: Microsoft.ReportViewer.WebForms (Microsoft.ReportViewer.WebForms.dll)
構文
'宣言
<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 _
)
'使用
Dim instance As LocalReport
Dim reportEvidence As Evidence
instance.ExecuteReportInCurrentAppDomain(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.")]
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
)
パラメーター
- reportEvidence
型: System.Security.Policy.Evidence
レポートに関するセキュリティ情報を含んでいる Evidence オブジェクト。
説明
重要
このメソッドが依存するコード アクセス セキュリティ (CAS) 機能は .NET Framework 4 では推奨されていないため、.NET Framework 4 ではこのメソッドの使用は推奨されません。代わりに、ReportViewer コントロールは常にサンドボックスで保護されたアプリケーション ドメインで実行されます。AddFullTrustModuleInSandboxAppDomain および SetBasePermissionsForSandboxAppDomain を使用する必要があります。.NET Framework 4 でこのメソッドを引き続き使用する場合は、ASP.NET アプリケーションの Web.config ファイルで <NetFx40_LegacySecurityPolicy> 構成要素を使用する必要があります。使用しない場合、このメソッドは InvalidOperationException をスローします。
詳細については、「Code Access Security Policy Compatibility and Migration」を参照してください。
レポートの式は、Execution セキュリティ権限フラグだけを持つ現在の AppDomain で実行されます。既定では、このモードでカスタム アセンブリを使用できません。.NET Framework 3.5 では、これは信頼されているレポートに使用する既定のモードです。.NET Framework の各バージョンの既定のアプリケーション ドメイン モードについては、次の表を参照してください。
.NET Framework のバージョン |
LegacySecurityPolicy が有効かどうか |
既定のアプリケーション ドメイン |
利用可能なアプリケーション ドメイン モード |
4 |
無効 (既定値) |
サンドボックス |
サンドボックス |
4 |
有効 |
現在 |
サンドボックスおよび現在 |
3.5 |
N/A |
現在 |
サンドボックスおよび現在 |
このモードは、信頼されている処理拡張機能を使用している信頼されていないレポートの実行にも使用できます。
信頼されている処理拡張機能を許可するには、アプリケーションで AddTrustedCodeModuleInCurrentAppDomain を呼び出す必要があります。
使用例
この例では、テキスト ファイルからデータを読み取る単純なユーティリティ関数を含んでいるカスタム アセンブリがレポートの式として使用されています。
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;
}
}
次のコードを使用して、カスタム アセンブリを含んでいるレポートを現在の 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");