I'm following this document in order to run my website in a medium trust environment. My web app uses OleDb, so I need to give it permission in medium trust. I've done everything that is in that article and it's still not working :(

In my web_mediumtrust.config I've added the following security class:

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

And the following permission set:

<PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
   <IPermission class="OleDbPermission" version="1" Unrestricted="true" />
</PermissionSet>

But I still get an exception when I try to use it:

System.Security.SecurityException occurred Message="Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." Source="mscorlib"
StackTrace: at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.PermissionSet.Demand() at System.Data.Common.DbConnectionOptions.DemandPermission() at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection blah blah blah....

Is there something I'm missing? Do I have to do anything else?

Kind regards.

Accepted Answer

there is a configuration folder for x32:

%windir%\Microsoft.NET\Framework\{version}\CONFIG

and another for x64:

%windir%\Microsoft.NET\Framework64\{version}\CONFIG

I feel such as stupid...

Written by vtortola
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki