LocalReport.ExecuteReportInCurrentAppDomain 方法 (Evidence)
注意: 此 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 ExecuteReportInCurrentAppDomain(
Evidence reportEvidence
)
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 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
<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
)
參數
reportEvidence
Type: System.Security.Policy.EvidenceEvidence 物件,其中包含報表的安全性資訊。
註解
重要
這個方法已被取代的 .NET Framework 4 因為程式碼存取安全性 (CAS) 功能依賴中已被取代 .NET Framework 4。 相反地,ReportViewer 控制項永遠會在沙箱應用程式定義域中執行。 您應該使用 AddFullTrustModuleInSandboxAppDomain 和 SetBasePermissionsForSandboxAppDomain。 如果您想要繼續使用這個方法與 .NET Framework 4,您必須使用 ASP.NET 應用程式的 Web.config 檔案中。 否則,這個方法會擲回 InvalidOperationException。
如需詳細資訊,請參閱 程式碼存取安全性原則相容性和移轉。
報表中的運算式將會執行在目前 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");
另請參閱
LocalReport 類別
Microsoft.Reporting.WinForms 命名空間
回到頁首