Wednesday, December 14, 2005

Adventures with WSS and Workflow Foundation: Assembly does not allow partially trusted callers

I'm currently working on an article about combining Workflow Foundation and Windows SharePoint Services 2003. I'm using a document library event handler to call into a workflow created with Windows Workflow Foundation which I expose through a webservice. But at a certain point I got this error:

Event Type: Error
Event Source: Windows SharePoint Services 2.0
Event Category: Devices
Event ID: 1000
Date: 14/12/2005
Time: 16:31:36
User: N/A
Computer: SPS1
Description:
Unable to instantiate event handler (assembly "DocLibEventSink, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a219993018140b5e", class "DocLibEventSink.EventSink"), or report event for "Shared Documents/camlquery.txt" in "Shared Documents". System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at DolmenWorkflow.Workflow1_WebService..ctor()
at Service..ctor()
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
DolmenWorkflow, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null
The Zone of the assembly that failed was:
MyComputer
The Url of the assembly that failed was:
file:///C:/Inetpub/wwwroot2/dolmenwfservice/bin/DolmenWorkflow.DLL
--- End of inner exception stack trace ---


Luckily I found the answer through Google - Using Libraries from Partially Trusted Code. Since the SharePoint document library event handler needs to be deployed into the Global Assembly Cache (GAC), I also needed to deploy the DolmenWorkflow assembly into the GAC. Another workaround would have been to use the AllowPartiallyTrustedCallersAttribute

References:
  • Official Microsoft Windows Workflow Foundation website

  • Download Windows Workflow Foundation Beta 1.2 (for Office "12" Beta 1) - for Visual Studio 2005 RTM

  • 1 comment:

    Anonymous said...

    Thanks a lot. That helps

    Parag Sinkar