From: Supun on
I'm using few reports with parameters in asp .net 4.0.

As long as the roles and membership are turned off they works fine. After
turning on them if I try to run them without any changes, the report viewer
displays.

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=b77a5c561934e089' failed.

If I disable the parameters they works as usual.

Afetr searching for cause I found that this code will solve it.

ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);

But in .net 4.0 I can't use this anymore because it say's this method is
deprecated, it also mentions about using
"ReportViewer1.LocalReport.AddFullTrustModuleInSandboxAppDomain" instead. But
I can't get that to work.

Any help greatly appreciated.

From: Supun on
I solved this by adding the following line to the page.

ReportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(new
System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted));

I'm not sure about the security of this method yet.

"Supun" wrote:

> I'm using few reports with parameters in asp .net 4.0.
>
> As long as the roles and membership are turned off they works fine. After
> turning on them if I try to run them without any changes, the report viewer
> displays.
>
> 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=b77a5c561934e089' failed.
>
> If I disable the parameters they works as usual.
>
> Afetr searching for cause I found that this code will solve it.
>
> ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);
>
> But in .net 4.0 I can't use this anymore because it say's this method is
> deprecated, it also mentions about using
> "ReportViewer1.LocalReport.AddFullTrustModuleInSandboxAppDomain" instead. But
> I can't get that to work.
>
> Any help greatly appreciated.
>