Wednesday, May 28, 2008

SharePoint MOSS 2007 - Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data...' failed

Working on my first webpart using code from one of our ASP.NET monkeys, I ran into this error when I tried to do a simple query:


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


I found my answer in a form post which I'll reprint here (http://www.eggheadcafe.com/software/aspnet/30460745/request-for-the-permissio.aspx)

---

Anything that access database from SharePoint requires at least the WSS_Medium security policy in the web.config file.

Fix:
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.

Copy from mediumtrust.config:

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

to the <SecurityClasses> node of wss_minimaltrust.config.

In the PermissionSet section of the wss_mediumtrust.config file, copy the following:

<IPermission class="SqlClientPermission" version="1" Unrestricted="true"/>

into the a <lPermissionSet> node of wss_minimaltrust.config.

restart iis.

No comments: