You can add permission, including ReflectionPermission, OleDbPermission, and FileIOPermission, to the web.config file. Note that ComponentOne controls will not work in an environment where reflection is not allowed. Complete the steps in the Modifying or Editing the Config File topic to create or modify a policy file before completing the following.

ReflectionPermission

By default ReflectionPermission is not available in a medium trust environment. ComponentOne ASP.NET controls require reflection permission because LicenseManager.Validate() causes a link demand for full trust.

To add reflection permission, complete the following:

1.   Open the web_mediumtrust.config file or a file created based on the web_mediumtrust.config file.

2.   Add the following <SecurityClass> tag after the <SecurityClasses> tag so that it appears similar to the following:

<SecurityClasses>

    <SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

...

</SecurityClasses>

3.   Add the following <IPermission> tag after the <NamedPermissionSets> tag so it appears similar to the following:

<NamedPermissionSets>

     <PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">

        <IPermission

            class="ReflectionPermission"

            version="1"

            Flags="ReflectionEmit,MemberAccess" />

        ...

     </PermissionSet>

</NamedPermissionSets>

4.   Save and close the web_mediumtrust.config file.

OleDbPermission

By default OleDbPermission is not available in a medium trust environment. This means you cannot use the ADO.NET managed OLE DB data provider to access databases. If you wish to use the ADO.NET managed OLE DB data provider to access databases, you must modify the web_mediumtrust.config file.

To add OleDbPermission, complete the following steps:

1.   Open the web_mediumtrust.config file or a file created based on the web_mediumtrust.config file.

2.   Add the following <SecurityClass> tag after the <SecurityClasses> tag so that it appears similar to the following:

<SecurityClasses>

    <SecurityClass Name="OleDbPermission" Description="System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

...

</SecurityClasses>

3.   Add the following <IPermission> tag after the <NamedPermissionSets> tag so it appears similar to the following:

<NamedPermissionSets>

     <PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">

        <IPermission class="OleDbPermission" version="1" Unrestricted="true"/>

        ...

     </PermissionSet>

</NamedPermissionSets>

4.   Save and close the web_mediumtrust.config file.

FileIOPermission

By default, FileIOPermission is not available in a medium trust environment.  This means no file access is permitted outside of the application's virtual directory hierarchy.  If you wish to allow additional file permissions, you must modify the  web_mediumtrust.config file. 

To modify FileIOPermission to allow read access to a specific directory outside of the application's virtual directory hierarchy, complete the following steps:

1.   Open the web_mediumtrust.config file or a file created based on the web_mediumtrust.config file.

2.   Add the following <SecurityClass> tag after the <SecurityClasses> tag so that it appears similar to the following:

<SecurityClasses>

    <SecurityClass Name="FileIOPermission" Description="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

...

</SecurityClasses>

3.   Add the following <IPermission> tag after the <NamedPermissionSets> tag so it appears similar to the following:

<NamedPermissionSets>

    <PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">

    ...

    <IPermission class="FileIOPermission" version="1" Read="C:\SomeDir;$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />

  ...

</PermissionSet>

</NamedPermissionSets>

4.   Save and close the web_mediumtrust.config file.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.