PDA

View Full Version : LinqDataSource in medium trust throws System.Security.SecurityException at runtime


asljussar
12-27-2007, 02:12 AM
I am getting this error:
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.


This error is a known issue in Asp.Net 3.5 beta 2.

This is the proposed fix that is documented in:
http://download.microsoft.com/download/d/d/1/dd18043a-fe86-4f57-ac22-791b30e6f04b/dotNetReadme.htm
"2.3.1.5 In ASP.NET, LinqDataSource in medium trust throws System.Security.SecurityException at runtime



In ASP.NET, if an application is run in medium trust, the LinqDataSource control raises the followingruntime exception:


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


To resolve this issue:



1. Open the web_mediumtrust.config file that is installed in the following location:

%WINDIR%\Microsoft.NET\Framework\v2.0.50727\CONFIG \

2. Make the following two changesin this file
a. Under the <SecurityClasses> element, add a nested entry for a new Security Class. The location where it is entered is not important, as long as it is nested under the <SecurityClasses> element.

<SecurityClasses>
....
<!-- this SecurityClass section is thework around for the compilation issue -->
<SecurityClass
Name="ReflectionPermission"
Description="System.Security.Permissions.ReflectionPermission,
mscorlib,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
/>
</SecurityClasses>

b. In the <NamedPermissionSets> section, add a <IPermission> element for reflection permission nested in the ASP.NET <PermissionSet> as shown below:

<NamedPermissionSets>

<PermissionSet
class="NamedPermissionSet"
version="1"
Name="ASP.Net">
...
<!-- this IPermission section is thework around for the reflection issue -->
<IPermission
class="ReflectionPermission"
version="1"
Flags="RestrictedMemberAccess"
/>
</PermissionSet>
...

</NamedPermission>


It does not matter where the <IPermission> section is placed under the ASP.NET permission set element. As long as it is a nested element.


3. Save and close the file."

Could you please upgrade ASP.NET in the IIS7 beta server to the latest release (3.5 RTM) or apply the suggested fix.

Thanks,

bruce
12-27-2007, 08:35 AM
We do not have immediate plan for upgrading the .net 3.5 framework on the beta server due to the proximity to the release date for Longhorn.

.NET 3.5 is already available on all the production servers.

Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

wisemx
12-27-2007, 08:38 AM
That does make sense, to me anyway...
Hope most everyone agrees with you bro as it does seem to be on the right track. http://community.discountasp.net/emoticons/wink.gif