2009-06-09 35 views
0

是否有人使用WSP Builder打包使用配置存儲(http://www.codeplex.com/SPConfigStore)並部署到Web應用程序的bin目錄的解決方案?WSPBuilder,配置存儲和部分信任的調用者

當我嘗試referecne配置存儲在隱藏文件我得到這個例外,我的代碼...

System.Security.SecurityException:該程序集不允許部分受信任的調用方

我已經添加了部分受信任的調用方屬性到我的項目

[assembly: AllowPartiallyTrustedCallers()] 

和SharePoint權限對我的方法

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

但是這似乎並沒有做任何事情,我也指定用正確的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" /> 

而且仍然沒有成功的自定義CAS策略,想必其他人都這樣做了,我必須缺少的東西

我正在使用WSP Builder版本1.0.5。

回答

1

您已將[assembly:AllowPartiallyTrustedCallers()]添加到您的程序集中,因此您的程序集將允許部分受信任的調用者致電IT。 但ConfigStore本身沒有該屬性。

是否可以將您的DLL添加到GAC? (簡單的辦法)。 或將[assembly:AllowPartiallyTrustedCallers()]添加到ConfigStore項目中。

+0

ConfigStore在GAC中是否需要該屬性?我認爲GAC中的所有程序集都完全可信。 ConfigStore源代碼可用,所以這是可能的。 – Rob 2009-06-09 10:01:53

+0

程序集位於GAC中時,它本身自動完全受信任。這並不意味着它允許部分受信任的程序集調用。我認爲... – Colin 2009-06-09 10:07:44

0

您是否將程序集添加到web.config SafeControls部分?你

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

可能還需要降低在web.config中的信任級別:

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

請參閱MSDN文檔的ASP.Net and SharePoint trust levels

+0

是添加了安全控件。我不確定如何降低信任級別,因爲我認爲這是問題 - 如果我將信任級別設置爲完整,代碼將運行。然而,這只是我的彙編,我想要有權限運行代碼。 – Rob 2009-06-09 09:20:08

+0

你簽署了大會嗎? – Moo 2009-06-09 09:34:40

+0

是的,WSPBuilder自動創建並簽署項目。 – Rob 2009-06-09 10:06:40