Tuesday, January 18, 2011

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

In this post we will discuss how to resolve the below error:
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

Also you can check out my previous posts on:

- Share with everyone new feature in SharePoint 2013

- Show SharePoint list data in repeating table in infopath 2010 using SharePoint object model

- Display or Hide Quick Launch SharePoint 2010

I got through the below error while working in developing a custom web part in sharepoint 2010.

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

I was using enterprise library for database communications.

Solution:
Go to the below directory (Hope you have default installation path, else you can change the path accordingly)
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG

Then open the wss_mediumtrust.config and wss_minimaltrust.config file. Be sure to take back up of both these files before modifying it.

Step:1
Copy the below line from wss_mediumtrust.config

SecurityClass
Name="SqlClientPermission"
Description="System.Data.SqlClient.SqlClientPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

And paste it in inside node of wss_minimaltrust.config

Step:2
Copy the below line from wss_mediumtrust.config file

ipermission class="SqlClientPermission" version="1" Unrestricted="true"

And Paste it in node of wss_minimaltrust.config

After that I think it will work. Please let me if it will impact ant sharepoint behaviour.

2 comments:

  1. It worked for me previously ! U may try some different solution http://www.enjoysharepoint.com

    ReplyDelete