Error Using CreateWorkItem from AgilePart
Symptoms
Calling CreateWorkItem with the following parameters inside an AgilePart causes this error:
Object reference not set to an instance of an object.
api.CreateWorkItem(w.ActivityInstID, "Process Step", "Administrator",
new WFTimeDuration(1, WFTimeUnit.DAY, false),
string.Empty);
Cause
CreateWorkItem API must be called from a manual activity.
Resolution
CreateWorkItem is an API to create a new work item from an existing manual activity. There is a similar API called CreateLinkedWorkitem which is used to create a new work item that links the new item with the existing work item. Both of these API can be used from an AgileWork. The activity instance ID in CreatWorkItem must be a manual activity instance ID. api.CreateWorkItem( manualActivityInstanceID, ...)
In other words, they can not be used in an AgilePart or AgileStub. This is why the error occurs.