文章目錄
- LocalReport.SetBasePermissionsForSandboxAppDomain 方法
An error occurred during local report processing.Failed to load expression host assembly. Details: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0,Culture=neutral, PublicKeyToken=b77a5c561934e0
解決方案,為ReportViewer的LocalReport設定許可權:
var reportInstance = new LocalReport();reportInstance.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
I don't really understand why. I do understand that the report is being granted permissions it can't get from WIF, but I don't understand which permissions those are or why it needs them. So, my answer "gives a man a fish," but can someone else "teach a man to fish" by explaining the deeper issue?
LocalReport.SetBasePermissionsForSandboxAppDomain 方法
為Vs2010新添加的方法。使用提供的許可權集設定沙箱應用程式域的基本許可權。
沙箱應用程式域中的基本許可權應用於自訂代碼程式集和報表運算式的計算。請注意,此方法將所有現有基本許可權集替換為提供的許可權集。您應當確保提供的許可權集包括 Execution許可權。否則,將無法執行任何自訂代碼程式集,且無法計算任何錶達式。
如果您更改了許可權,請確保不能使用 LocalReport 對象訪問任何不可信的報表定義。在 .NET Framework 3.5(或啟用了 LegacySecurityPolicy 的 .NET Framework 4 中),必須顯式調用 ExecuteReportInSandboxAppDomain 方法才能切換到沙箱應用程式域模式。
http://msdn.microsoft.com/zh-cn/library/microsoft.reporting.webforms.localreport.aspx
http://stackoverflow.com/questions/4794968/reporting-services-localreport-and-wif