Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created a sandbox solution that creates following:

  • Site Columns
  • Content Type with these site columns
  • A list based on this content type
  • Attaching a workflow to the content type and push it down to the lists based on that content type.

But at this last step it fails.

When i developped it on my local machine it worked perfect, but when I activate the solution on an other sharepoint it fails.

My code:

string workflowTemplateName = Resources.ContactFormWorkflowName;
string listTaskName = Resources.WorkflowTasksListName;
string listHistoryName = Resources.WorkflowHistoryListName;

foreach (SPWorkflowTemplate workflowTemplate in web.WorkflowTemplates)
{
   if (workflowTemplate.Name == workflowTemplateName)
   {

      // Create History List
      SPList historylist = web.Lists.TryGetList(listHistoryName);
      if (historylist == null)
      {
         web.Lists.Add(listHistoryName, listHistoryName, SPListTemplateType.WorkflowHistory);
         historylist = web.Lists.TryGetList(listHistoryName);
      }

      // Create Task List
      SPList tasklist = web.Lists.TryGetList(listTaskName);
      if (tasklist == null)
      {
         web.Lists.Add(listTaskName, listTaskName, SPListTemplateType.Tasks);
         tasklist = web.Lists.TryGetList(listTaskName);
      }

      SPWorkflowAssociation association = SPWorkflowAssociation.CreateListContentTypeAssociation(workflowTemplate,
                                                      workflowTemplateName,
                                                      tasklist,
                                                      historylist);

       association.AllowManual = true;
       association.AutoStartCreate = true;
       association.AutoStartChange = false;
       ct.WorkflowAssociations.Add(association);
       ct.Update();
       ct.UpdateWorkflowAssociationsOnChildren();
       ct.Update();
    }
 }

If i remove ct.UpdateWorkflowAssociationsOnChildren(); it works, but the workflow is not associated to my list (only the content type). If i do not remove it, i get the fantastic error:

    <nativehr>0x80070005</nativehr><nativestack></nativestack>

If I copy the same code in a console sharepoint application, it works... But uploading as a Sandbox WSP it fails.

Complete error:

Feature Activation: Threw an exception, attempting to roll back. Feature 'ContactForm.Workflows_Feature1' (ID: '951c4afe-cf8a-4874-afb6-9d4b80119f0b'). Exception: Microsoft.SharePoint.UserCode.SPUserCodeSolutionExecutionFailedException: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred. ---> Microsoft.SharePoint.UserCode.SPUserCodeSolutionProxiedException: 0x80070005 Server stack trace: at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwSynchronization, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, Guid solutionId, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId) at Microsoft.SharePoint.SPEventReceiverDefinition.RegisterForSiteOrWebOrList(Operation operation, Boolean isMigration) at Microsoft.SharePoint.Workflow.SPWorkflowManager.CreateListSubscription(SPList listElev, Type handlerClass, SPEventReceiverType rt, String filter, String strData) at Microsoft.SharePoint.Workflow.SPWorkflowManager.<>c_DisplayClass27.b_24() at Microsoft.SharePoint.SPSecurity.<>c_DisplayClass4.b_2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.SharePoint.Workflow.SPWorkflowManager.AddAutoStartToList(SPList list, Boolean bCreate, Boolean bChange) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.AddCore(SPWorkflowAssociation wa, Guid id, SPList list, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPListWorkflowAssociationCollection.Add(SPWorkflowAssociation workflowAssociation) at Microsoft.SharePoint.Workflow.SPListWorkflowAssociationCollection_SubsetProxy.Add__Inner(SPWorkflowAssociation_SubsetProxy workflowAssociation) at Microsoft.SharePoint.Workflow.SPListWorkflowAssociationCollection_SubsetProxy.Add(SPWorkflowAssociation_SubsetProxy workflowAssociation) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.SharePoint.Workflow.SPListWorkflowAssociationCollection_SubsetProxy.Add(SPWorkflowAssociation_SubsetProxy workflowAssociation) at Microsoft.SharePoint.Workflow.SPListWorkflowAssociationCollection.Add__Inner(SPWorkflowAssociation workflowAssociation) at Microsoft.SharePoint.Workflow.SPListWorkflowAssociationCollection.Add(SPWorkflowAssociation workflowAssociation) at Centric.SharePoint.ContactForm.Workflows.ContactFormWorkflow.CreateContactFormWorkflow(SPWeb web, SPContentType ct) at ContactForm.Workflows.Features.Feature1.Feature1EventReceiver.FeatureActivated(SPFeatureReceiverProperties properties) at Microsoft.SharePoint.UserCode.SPUserCodeFeatureCallOutWrapper.ExecuteInternal(Object userCodeObject, SPUserCodeRemoteExecutionContext context) at Microsoft.SharePoint.UserCode.SPUserCodeRemoteExecutionWrapper.Execute(SPUserCodeExecutionContext executionContext) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.ExecuteWrapper(SPUserCodeWrapper wrapper, SPUserCodeExecutionContext executionContext) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink) Exception rethrown at [1]: at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase) at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.CodeToExecuteWrapper.EndInvoke(IAsyncResult result) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext, Boolean shouldUsageLog, Int32 currentProcessId) --- End of inner exception stack trace --- Server stack trace: at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext, Boolean shouldUsageLog, Int32 currentProcessId) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext, Boolean shouldUsageLog, Int32 currentProcessId) at Microsoft.SharePoint.UserCode.SPUserCodeAppDomain.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext, Boolean shouldUsageLog, Int32 currentProcessId) at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxyForShim.ExecuteInternal(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxy.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.ExecuteDelegate.EndInvoke(IAsyncResult result) at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String currentAffinity, SPUserCodeExecutionContext executionContext) at Microsoft.SharePoint.UserCode.SPUserCodePoolableProcessConnection.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext) at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [1]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinityBucketName, SPUserCodeExecutionContext executionContext) at Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(Type userCodeWrapperType, SPSite site, SPUserCodeExecutionContext executionContext) at Microsoft.SharePoint.Administration.SPFeatureDefinition.<>c_DisplayClass1.b__0() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.Administration.SPFeatureDefinition.DoSPUserFeatureCallout(SPSite site, SPWeb web, SPFeatureCallOutOperation operation, String solutionHash, String solutionValidatorHash, String solutionValidationErrorUrl, String solutionValidationErrorMessage, String customActionName, IDictionary`2 parameters) at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I deployed it on an other machine and there works it also fine. Seems that it is an issue typical to that specific environment

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.