Saturday, July 13, 2013

System.Security.SecurityException Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

I got this error while publishing an Infopath form which has object model code in SharePoint 2010. The full error message is "System.Security.SecurityException
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.".

Also you can check out my previous posts on:
- Fix width of master page in SharePoint 2010

- Tutorial on User Profile service application in SharePoint 2013

- Custom timer job sharepoint 2010

Reason:
By default SharePoint is configured with a security policy called WSS_Minimal.  This policy definition does not grant access to the SharePoint object model.

Solution:
We need to give full trust level in web application web.config file. For this Navigate to C:\inetpub\wwwroot\wss\VirtualDirectories\80\<Web Application>

Add the below line to the web applications web.config file in system.web section:

<trust level="Full" originUrl="" />

Now it should work.

No comments:

Post a Comment