Question

Has anyone used WSP Builder to package a solution that uses the Config Store (http://www.codeplex.com/SPConfigStore) and deploys to the bin directory of the web application?

When I try to referecne the config store in my code behind file I get this exception...

System.Security.SecurityException: That assembly does not allow partially trusted callers

I've added the partially trusted callers attribute to my project

[assembly: AllowPartiallyTrustedCallers()]

and the sharepoint permissions attributes on my methods

[SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, Impersonate = true)] 
[SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, ObjectModel = true)]

But this hasn't seem to have done anything, I've also specified a custom CAS policy with the correct IPermission

<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" />

And still no success, surely other people have done this, I must be missing something

I'm using WSP Builder version 1.0.5.

Was it helpful?

Solution

You have added the [assembly: AllowPartiallyTrustedCallers()] to YOUR assembly, so your assembly WILL allow for partially trusted callers to call IT. But the ConfigStore itself does not have that attribute.

Is it possible to add your DLL to the GAC? (easy way out). Or add the [assembly: AllowPartiallyTrustedCallers()] to the ConfigStore project as well..

OTHER TIPS

Did you add the assembly to the web.config SafeControls section?

<SafeControl Assembly="Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.Office.Server.Search.WebControls" TypeName="*" Safe="True" />

Also you may need to lower the trust level in the web.config:

<trust level="WSS_Minimal" originUrl="" />

See the MSDN docs for ASP.Net and SharePoint trust levels.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top