Vishwamohan

Welcome to Vishwa's blog - Technology, Spirituality and More...

Error: The application attempted to perform an operation not allowed by the security policy.

You may come across this error. It will appear that there is something wrong with your code, but solution is very simple.

Security Exception may look like following


Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

 

Stack Trace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.SpecialDemand(PermissionType whatPermission, StackCrawlMark& stackMark) +0
   System.Security.CodeAccessPermission.Demand(PermissionType permissionType) +28

 

Resolution:

Add or ensure the following setting in your web.config

<system.web>

<trust level="Full"/>

</system.web>

Loading