Sharepoint and TaskListContentTypeId with mixing Office workflow tasks with regular sharepoint workflow tasks.
We have a workflow that is a mix of simple tasks and MOSS infopath forms server workflow tasks.
To that end we remove the TaskListContentTypeId from workflow.xml and use the CreateTaskWithContentType shape to manually set the content type on appropriate tasks. This works fine until we come to deploy on a fresh sharepoint site.
We get some kind of error in the sharepoint logs:
110/15/2007 15:29:09.76 w3wp.exe (0x145C) 0x144C Windows SharePoint Services Workflow Infrastructure 72ew Medium Object reference not set to an instance of an object. 10/15/2007 15:29:09.78 w3wp.exe (0x145C) 0x144C Windows SharePoint Services Workflow Infrastructure 88xr Unexpected WinWF Internal Error, terminating workflow Id# c345e730-f40d-4cb9-8197-f472143c8410 10/15/2007 15:29:09.78 w3wp.exe (0x145C) 0x144C Windows SharePoint Services Workflow Infrastructure 98d4 Unexpected System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTaskWithContentTypeInternal(Guid taskId, SPWorkflowTaskProperties properties, Boolean useDefaultContentType, SPContentTypeId ctid, HybridDictionary specialPermissions) at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTaskWithContentType(Guid taskId, SPWorkflowTaskProperties properties, String taskContentTypeId, HybridDictionary specialPermissions) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.\_InvokeMethodFast(Object target, Object\[\] arguments, SignatureStruct& sig, MethodAttributes methodAtt... 10/15/2007 15:29:09.78\* w3wp.exe (0x145C) 0x144C Windows SharePoint Services Workflow Infrastructure 98d4 Unexpected ...ributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object\[\] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object\[\] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object\[\] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object\[\] providedArgs, ParameterModifier\[\] modifiers, CultureInfo culture, String\[\] namedParams) at System.Workflow.Activities.CallExternalMethodActivity.Execute(Acti... 10/15/2007 15:29:09.78\* w3wp.exe (0x145C) 0x144C Windows SharePoint Services Workflow Infrastructure 98d4 Unexpected ...vityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor\`1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor\`1.Execute(Activity activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()
Which tells us a little, but not much.
So after a few :ahem: hours of digging around. It turns out that the problem manifests itself because when a tasklist for a wf instance is created by associating a workflow with a list - it sets up content types in the task list which sharepoint uses to marshal tasks. We weren't seeing the problem because we only started using CreateTaskWithContentType activities half way through the development cycle.
We can see this by looking at the task list, going to "Settings"..."Advanced Settings", and checking "Allow management of content types". OK that and scroll down the summary screen and there *should* be a content type named "Office SharePoint Server Workflow Task". If there is not you need to associate the content type with the task list and everything should be tickety boo. (you can do this quick and dirty by adding the content type id to the workflow.xml and recreating the task list when you assign the workflow).
If you click "Add from existing site content types" the type will not be visible. I will update when I find how you do this.