次の方法で共有


LocalReport.AddTrustedCodeModuleInCurrentAppDomain メソッド (String)

 

注: この API は、互換性のために残されています。

現在の実行が信頼されているアセンブリの一覧に、指定したアセンブリを追加 AppDomainします。

名前空間:   Microsoft.Reporting.WinForms
アセンブリ:  Microsoft.ReportViewer.WinForms (Microsoft.ReportViewer.WinForms.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 void AddTrustedCodeModuleInCurrentAppDomain(
    string assemblyName
)
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 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
<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
)

パラメーター

  • assemblyName
    Type: System.String

    追加するアセンブリの名前。

備考

重要

このメソッドは非推奨 .NET Framework 4 コード アクセス セキュリティ (CAS) 機能に依存しているためには使用されなくなりましたで .NET Framework 4 です。 代わりに、ReportViewer コントロールは、サンド ボックス アプリケーション ドメインで常に実行されます。 使用する必要があります AddFullTrustModuleInSandboxAppDomainSetBasePermissionsForSandboxAppDomainです。 このメソッドの使用を継続するかどうかは .NET Framework 4 が使用する必要があります、ASP.NET アプリケーションの Web.config ファイルにします。 それ以外の場合、このメソッドをスローする InvalidOperationExceptionです。

このメソッドは引き続き機能と .NET Framework 3.5。

詳細については、次を参照してください。 コード アクセス セキュリティ ポリシーの互換性と移行します。

レポート内の式は、現在の実行は AppDomain だけを持つ、 実行 セキュリティ権限フラグ。 既定では、カスタム アセンブリは、このモードでは許可されません。AddTrustedCodeModuleInCurrentAppDomain メソッドは、現在のカスタム アセンブリの使用を許可するように使用できる AppDomainです。

渡されたアセンブリの名前、 assemblyName で指定されているパラメーターを一致させる、 CodeModule レポート定義ファイルの要素。

使用例

この例では、階乗を計算する単純なユーティリティ関数を含んでいるカスタム アセンブリは、レポートの式として使用します。

using System.IO;
using System.Reflection;

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 オンライン ブックを参照してください。

関連項目

LocalReport クラス
Microsoft.Reporting.WinForms 名前空間

トップに戻る