Title

Kodyaz Development Resources

Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.
Welcome to Kodyaz Development Resources Sign in | Join | Help
in Search

Eralper's Blog on Software Development



Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Hi,

In my Reporting Services application I'm using Custom Code in which I have developed a custom function. In this custom function, I'm using the

System.Reflection.Assembly.LoadWithPartialName

method in order to load localization assemblies and get my localization strings and regional settings according to the user's culture.

After I've migrated the reporting services application from SSRS 2000 to SSRS 2005, I got the following error messages in the test servers.

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I was successfull to get the sql batch that has been sent to database when I tried to trace the sql database with the SQL Server Profiler.

The profiler supplied me the following information :

--------------------------

Exec KODYAZ.DevelopmentDB.dbo.General_Management_DailySummaryReport '4605200600', '', '12/03/2007', '20/03/2007', -1,

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

---> System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)

at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)

at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)

at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)

at BSH.Octopus.SystemFramework.ResourceFactory.GetLocalizationString(String mLocalizationKeyName, Int16 mResourceName, String cultureName)

The action that failed was:

LinkDemand

The type of the first permission that failed was:

System.Web.AspNetHostingPermission

The Zone of the assembly that failed was:

MyComputer

--- End of inner exception stack trace ---

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

at ReportExprHostImpl.CustomCodeProxy.GetLocalDate(String CultureCode)

--------------------------

First, I used the SysInternal's Filemon.exe utility in order to see any file could not be accessed or blocked that may cause the problem.

But the error itself was already indicating that it is actually a code access security (CAS) configuration problem.

In order to solve the problem, I opened the rssrvpolicy.config reporting services configuration file in the ReportServer virtual directory of the IIS where the report server exists. That is the C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer folder with a default installation.

I updated the following CodeGroup block permission set from Nothing

<CodeGroup
                            class="FirstMatchCodeGroup"
                            version="1"
                            PermissionSetName="Nothing">

to FullTrust in order to let the application access the assemblies successfully.

<CodeGroup
                            class="FirstMatchCodeGroup"
                            version="1"
                            PermissionSetName="FullTrust">

 

Published Friday, April 13, 2007 9:15 AM by eralper
Filed Under: ,

Comments

No Comments
Anonymous comments are disabled
Copyright © 2004 - 2008 Eralper Yilmaz. All rights reserved.
Powered by Community Server, by Telligent Systems