27/02/2010 1 Comment
In first acticle we talk about how we configure our Ninject with Sharepoint .Now there are two issue one of them is our ninject dlls permissions and the your assemblies that using ninject should allow partially trust callers.
When you configure your ninject dll to sharepoint you probably encounter with permission denied errors . That is normal beacuse our custom Ninject Library is using Reflection and Sharepoint libraries and you have to define CAS for this libraries .
Setup your CAS
I’m using for deployment WSPBuilder tool and i use it with a customCAS file.There are two CAS permission as important
For deployment batch file contains that:
WSPBuilder.exe -WSPName Ninject.Deploy.wsp -CustomCAS CustomCAS.txt -SolutionID [Your Solution ID]
And you should copy CustomCAS.txt to same folder of WspBuilder.exe that contains
<IPermission class=”Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c” version=”1″ ObjectModel=”True” UnsafeSaveOnGet=”True” Unrestricted=”True” / >
<IPermission class=”System.Security.Permissions.ReflectionPermission, mscorlib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089″ version=”1″ Flags=”3″ Unrestricted=”True” / >
For more information WSPBuilder with custom CAS there is a simple post here:
For more info Microsoft Windows SharePoint Services and Code Access Security is Msdn
Allow Partially Trusted Callers
There is another job about your class or page assemblies that using ninject should be contains
attribute in your AssemblyInfo.cs file . (You should add refrence of “using System.Security;” namespace)
After build you can craete a setup with Sharepoint Solution Installer using your wsp file deploy without any further error.