2007-07-31

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

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:

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

    Copy and paste it in to the <SecurityClasses> node of wss_minimaltrust.config.

    In the PermissionSet section of this configuration file, add the following:
    Find in wss_mediumtrust.config: <IPermission class="SqlClientPermission" version="1" Unrestricted="true"/>

    Copy and paste it in to the a <PermissionSet> 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. Google it...

The file or folder name contains characters that are not permitted. Please use a different name.


Creating a new site based on a custom site definition, you get the above error.

 

Cause: This error is caused by one of the aspx files in your site definition referencing and invalid master page. ei not default.master

 

Work Around: The only work around I've found is to put your custom master page in the masterpage library of the top site.

 

Even if the master page exists in both \Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL & LAYOUTS it will not work.




Update:
OK had this issue again and its caused by the SP dll not finding the master page defined in the aspx page.

The fix is to make sure it can.

Options:

  • Put the masterpage at the site collection level, use it's absolute path (/_catalogs/masterpage/new.master or ~sitecollection/_catalogs/masterpage/new.master)
  • Use a site local masterpage library and use (~site/_catalogs/masterpage/new.master)