メモ: この 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 AddTrustedCodeModuleInCurrentAppDomain ( _
assemblyName As String _
)
'使用
Dim instance As LocalReport
Dim assemblyName As String
instance.AddTrustedCodeModuleInCurrentAppDomain(assemblyName)
[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 AddTrustedCodeModuleInCurrentAppDomain(
string assemblyName
)
[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 AddTrustedCodeModuleInCurrentAppDomain(
String^ assemblyName
)
[<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 AddTrustedCodeModuleInCurrentAppDomain :
assemblyName:string -> unit
public function AddTrustedCodeModuleInCurrentAppDomain(
assemblyName : String
)
パラメーター
- assemblyName
型: System.String
追加するアセンブリの名前。
説明
重要
このメソッドが依存するコード アクセス セキュリティ (CAS) 機能は .NET Framework 4 では推奨されていないため、.NET Framework 4 ではこのメソッドの使用は推奨されません。代わりに、ReportViewer コントロールは常にサンドボックスで保護されたアプリケーション ドメインで実行されます。AddFullTrustModuleInSandboxAppDomain および SetBasePermissionsForSandboxAppDomain を使用する必要があります。.NET Framework 4 でこのメソッドを引き続き使用する場合は、ASP.NET アプリケーションの Web.config ファイルで <NetFx40_LegacySecurityPolicy> 構成要素を使用する必要があります。使用しない場合、このメソッドは InvalidOperationException をスローします。
このメソッドは、.NET Framework 3.5 では、引き続き機能します。
詳細については、「Code Access Security Policy Compatibility and Migration」を参照してください。
レポートの式は、Execution セキュリティ権限フラグだけを持つ現在の AppDomain で実行されます。既定では、このモードでカスタム アセンブリを使用できません。AddTrustedCodeModuleInCurrentAppDomain メソッドを使用すると、現在の AppDomain でカスタム アセンブリの使用を許可できます。
assemblyName パラメーターで渡されたアセンブリの名前は、レポート定義ファイルの CodeModule 要素で指定した名前と同じである必要があります。
使用例
この例では、階乗を計算する単純なユーティリティ関数を含んでいるカスタム アセンブリがレポートの式として使用されています。
public class Util
{
public static int Factorial(int n)
{
return ((n <= 1) ? 1 : (n * Factorial(n - 1)));
}
}
次のコードは、現在の AppDomain にカスタム アセンブリを追加するために使用します。
reportViewer.LocalReport.ReportPath = "Report1.rdlc";
reportViewer.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(
"Contoso.Utilities,
Version=1.0.271.0, Culture=neutral,
PublicKeyToken=89012dab8080cc90");
カスタム アセンブリの詳細については、SQL Server オンライン ブックの「レポートでのカスタム アセンブリの使用」を参照してください。