views:

1167

answers:

2

Hi

I have a SharePoint WebPart project in visual studio. As part of the project I am referencing the interop.ActiveDS.dll.

I can compile the project successfully and add/deploy the solution to SharePoint. When I try to run the WebPart in SharePoint I get the error:

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

I have added [assembly: System.Security.AllowPartiallyTrustedCallers] to the assemblyinfo.cs file but this has not helped.

Would appreciate any answers for this!

+1  A: 

Deploying it to the GAC seems to be a possible solution:

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/f9bff1aa-007b-4933-bb5b-56a283aea227/

All the best

78lro
A: 

The problem is that Interop.ActiveDs.dll does not allow partially trusted callers. Your best bet is to deploy a signed interop assembly to the GAC:

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