SharePoint WebPart包和dll

时间:2009-01-13 11:38:14

标签: visual-studio sharepoint dll web-parts

我在visual studio中有一个SharePoint WebPart项目。作为项目的一部分,我引用了interop.ActiveDS.dll。

我可以成功编译项目并将解决方案添加/部署到SharePoint。当我尝试在SharePoint中运行WebPart时,我收到错误:

That assembly does not allow partially trusted callers.

[SecurityException: That assembly does not allow partially trusted callers.]
   PeopleAdWebPart.PeopleAdWebPart.OnLoad(EventArgs e) +0
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest(HttpContext context) +153
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

我已将[assembly:System.Security.AllowPartiallyTrustedCallers]添加到assemblyinfo.cs文件中,但这没有帮助。

对此感谢任何答案!

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

问题是Interop.ActiveDs.dll不允许部分信任的呼叫者。最好的办法是将签名的互操作程序集部署到GAC:

TlbImp %windir%\system32\ActiveDs.tlb /out:Interop.ActiveDs.dll /keyfile:KeyFile.snk