I have created a visual web part in Visual Studio 2010 which is to be deployed to the /bin directory of our SharePoint web applications. The idea being we can have a development, staging, UAT web application each using their own version of the web parts.
As it is to be deployed to the /bin directory I have edited the package xml to include CAS details
<CodeAccessSecurity> <PolicyItem> <PermissionSet class="NamedPermissionSet" version="1"> <IPermission class="SecurityPermission" version="1" Flags="Execution"/> <IPermission class="AspNetHostingPermission" version="1" Level="Minimal" /> <IPermission class="WebPartPermission" version="1" Connections="True" /> <IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" /> </PermissionSet> <Assemblies> <Assembly Name="$SharePoint.Project.AssemblyName$" Version="$SharePoint.Project.AssemblyVersion$" PublicKeyBlob="$SharePoint.Project.AssemblyPublicKeyBlob$"/> </Assemblies>
Note that I've also tried setting the Level to Medium on the AspNetHostingPermission line.
If I deploy this from Visual Studio, I can see the web part listed but I get an error when adding the part to the page. From various tinkering around I have had two messages:-
The file '/_CONTROLTEMPLATES/xxxxx/MyWebPart.ascx' does not exist
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
This makes me think there is a problem with my CAS policy, but I'm at a lost to determine the error. Does anybody have any pointers for me?