Running Microsoft Enterprise Library in Medium Trust

Error:

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

[PolicyException: Required permissions cannot be acquired.]

System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +7602199

System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

 

[FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]

 

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]

Fix:

As noted in the error message, you are using Microsoft Enterprise Library version 2.0.0.0. According to MSDN, Microsoft Enterprise Library version 3.1 should work in a partially trusted environment. You will run into the "requirePermission" error as noted above, but that can be easily fixed with a small change to the web.config

We have also discovered the following website which contains a ZIP of working Enterprise Library DLLs for medium trust. You can test these DLLs for the customer by backing up their old DLLs and using these new ones or suggest they update their website with these DLLs.

http://www.stuffthatjustworks.com/HowToRunEnterpriseLibraryUnderMediumTrust.aspx