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 控制項永遠會在沙箱應用程式定義域中執行。 您應該使用 AddFullTrustModuleInSandboxAppDomain 和 SetBasePermissionsForSandboxAppDomain。 如果您想要繼續使用這個方法與 .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 命名空間
回到頁首