Sunday 28 August 2011

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Sharepoint Webpart/Infopath Form

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
A Web part/InfoPath form with managed code causes the above error.

Cause: DLL's that access databases require at least the WSS_Medium security policy in the web.config file. If you receive a security message from the web part, it's usually the trust element in the web.config file.
You could also have a dll outside the GAC that's trying to access some part of the SharePoint Object Model.
Fix: There's a couple of ways to resolve this issue.

  1. Put you dll in the GAC. I don't like putting limited use web parts in there and managed code for InfoPath doesn't like it.

  2. Open wss_mediumtrust.config & wss_minimaltrust.config usually (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\) look in your web.config file for the exact path. Find in wss_mediumtrust.config: Copy and paste it in to the node of wss_minimaltrust.config.
    In the PermissionSet section of this configuration file, add the following: Find in wss_mediumtrust.config:
    Copy and paste it in to the a node of wss_minimaltrust.config. That about covers it

  3. You could also set the trust level to "wss_mediumtrust" or create a custom trust level. To create custom trust level see the post How to create cutom trust level in sharepoint

No comments:

Post a Comment