I wrote a timerjob how at some point creates an item and starts a workflow on that item manually. This works like 4 out of 5 times. When it doesn't work i get this not so cool exception:
Microsoft.SharePoint.SPException ---> System.Runtime.InteropServices.COMException (0x8102008A): <nativehr>0x8102008a</nativehr><nativestack></nativestack>
at Microsoft.SharePoint.Library.SPRequestInternalClass.AddWorkflowToListItem(String
bstrUrl, String bstrListName, Int32 lItemID, Int32 lItemLevel, Int32 lItemVersion, Guid
workflowPackageId, Guid& pWorkflowInstanceId, Guid workflowTaskListId, String
bstrStatusFieldInternalName, Int32 lAuthorId)
...
I start the WF like this:
public void StartWF(SPListItem item)
{
SPSite site = item.Web.Site;
SPWorkflowManager workflowManager = site.WorkflowManager;
SPWorkflowAssociation association = item.ContentType.WorkflowAssociations.GetAssociationByName("MyWfName", CultureInfo.CurrentUICulture);
workflowManager.StartWorkflow(item, association, "", SPWorkflowRunOptions.SynchronousAllowPostpone);
}
the exception is thrown in the owstimer.exe. I know that a workflow isn't startet when the system account is adding/updating an item, but i can start it in the code. But why doesn't it work 5 out of 5 times?