EntLib 2.0 and Medium Trust
We needed to make EntLib 2.0 work in medium trust scenarios. Unfortunately, it does not work out of the box. The EntLib team is working on a new build that will fix it, but meanwile I wanted to share what we needed to do.
We are basically using the Caching, Authorization and Encryption block.
To make it work, we had to remove most the permission demands form the AssemblyInfo.cs files. The only permission that can be declared without complains on build time is the [assembly: SecurityPermission(SecurityAction.RequestMinimum)]
FileConfigurationSourceImplementation fails because it tries to open machine.config and it's not possible. We did not find a workaround, so we stopped using FileConfigurationSource.
In the web.config <configSection> section you need to add the 'requirePermission="false"' to each entry, like:
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2.0.0.0, Culture=neutral, PublicKeyToken=387f38cffbc45540" requirePermission="false"/>
With these changes we made it work.
I hope it helps someone.