views:

47

answers:

0

Okay, i think most of you guys out there use wspbuilder to build the wsp solutions and to deploy it. So here is my problem.

I'm working on a SharePoint solution which makes use of a third party dll (Telerik for Asp.Net Ajax - Telerik.Web.UI.dll) for rich experience. Since Telerik dll is a common assembly i have to deploy it to the bin folder of the webapplication instead of GAC. So here comes the problem.

WSPBuilder automatically deploys the dll to gac if the dll presents in the GAC folder. To deploy the telerik dll in bin i created the folder 80\bin and copied the dll there. I tried to build the wsp again and then went through the manifest.xml created. Great. The deployment target for the dll changed to WebApplication and wspbuilder was smart to create the cas policy itself.

<CodeAccessSecurity>
        <PolicyItem>
            <PermissionSet class="NamedPermissionSet" version="1" Description="WSPBuilder generated permissionSet" Name="Telerik.Web.UI4a48967c-0673-4c67-a176-ca7c72c30c4d">
                <IPermission class="PrintingPermission" version="1" Level="DefaultPrinting" />
                <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter" />
                <IPermission class="SharePointPermission" version="1" ObjectModel="True" />
                <IPermission class="EnvironmentPermission" version="1" Read="TEMP;TMP;USERNAME;OS;COMPUTERNAME" />
                <IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Minimal" />
                <IPermission class="WebPartPermission" version="1" Connections="True" />
                <IPermission class="FileIOPermission" version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />
                <IPermission class="WebPermission" version="1">
                    <ConnectAccess>
                        <URI uri="$OriginHost$" />
                    </ConnectAccess>
                </IPermission>
                <IPermission class="IsolatedStorageFilePermission" version="1" Allowed="AssemblyIsolationByUser" UserQuota="9223372036854775807" />
                <IPermission class="DnsPermission" version="1" Unrestricted="true" />
                <IPermission class="SmtpPermission" version="1" Access="Connect" />
                <IPermission class="SqlClientPermission" version="1" Unrestricted="true" />
            </PermissionSet>
            <Assemblies>
                <Assembly Name="Telerik.Web.UI" Version="2010.2.826.35" PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010069F31F753C891D9F7F9D1CD0B579F61977769A5A48E01247CC2481C8765613854C8DCB5101DD092D5075A7339B4E34D0C9BD417F54972C7554AE480D6B1BB17BE8C1527554644BBD352D9498B174EAFF1090A30E1F7C2C3073669CB3EFC7D9640E82049F5FDA08CA58072C14169091A0BC7092EB6DE9C2A249A3C80F7704E5CF" />
            </Assemblies>
        </PolicyItem>
    </CodeAccessSecurity>

But Wspbuilder was not smart enough to put the four part name of SharePointPermission IPermission class. But i learnt that CAS actually requires the four part name. So i decided to make use of the -CustomCAS command line option of wspbuilder.exe to pass my custom cas policy file.

Here is my custom policy file -

<IPermission class="AspNetHostingPermission" version="1" Level="Minimal" />

<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execute" />

<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" UnsafeSaveOnGet="True" Unrestricted="True" />

<IPermission class="System.Security.Permissions.EnivronmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="UserName" />

So after building the wsp the cas section of the manifest.xml read this -

<CodeAccessSecurity>
        <PolicyItem>
            <PermissionSet class="NamedPermissionSet" version="1" Description="WSPBuilder generated permissionSet" Name="Telerik.Web.UIa2cbae96-9c52-459e-80f6-3391af7775ae">
                <IPermission class="PrintingPermission" version="1" Level="DefaultPrinting" />
                <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter" />
                <IPermission class="SharePointPermission" version="1" ObjectModel="True" />
                <IPermission class="EnvironmentPermission" version="1" Read="TEMP;TMP;USERNAME;OS;COMPUTERNAME" />
                <IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Minimal" />
                <IPermission class="WebPartPermission" version="1" Connections="True" />
                <IPermission class="FileIOPermission" version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />
                <IPermission class="WebPermission" version="1">
                    <ConnectAccess>
                        <URI uri="$OriginHost$" />
                    </ConnectAccess>
                </IPermission>
                <IPermission class="IsolatedStorageFilePermission" version="1" Allowed="AssemblyIsolationByUser" UserQuota="9223372036854775807" />
                <IPermission class="DnsPermission" version="1" Unrestricted="true" />
                <IPermission class="SmtpPermission" version="1" Access="Connect" />
                <IPermission class="SqlClientPermission" version="1" Unrestricted="true" />
                <IPermission class="AspNetHostingPermission" version="1" Level="Minimal" />

                <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execute" />

                <IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" UnsafeSaveOnGet="True" Unrestricted="True" />

                <IPermission class="System.Security.Permissions.EnivronmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="UserName" />
            </PermissionSet>
            <Assemblies>
                <Assembly Name="Telerik.Web.UI" Version="2010.2.826.35" PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010069F31F753C891D9F7F9D1CD0B579F61977769A5A48E01247CC2481C8765613854C8DCB5101DD092D5075A7339B4E34D0C9BD417F54972C7554AE480D6B1BB17BE8C1527554644BBD352D9498B174EAFF1090A30E1F7C2C3073669CB3EFC7D9640E82049F5FDA08CA58072C14169091A0BC7092EB6DE9C2A249A3C80F7704E5CF" />
            </Assemblies>
        </PolicyItem>
    </CodeAccessSecurity>

After i deployed the wsp i verified

* the dlls going to bin
* the trust level changed to custom trust level
* custom policy file being added to config folder

But when i run the page i get the following error -

screen shot -

alt text

Error -

Execution Permission Denied

Stack Trace -

Tell me if you want the stack trace. It is kind of annoyingly big.

I've checked my entire application for any assembly references of the dll. But i was not able to find one. Any ideas?