I've created site columns and added them to a custom Content Type.

I've then associated a workflow against this content type and then setup a document library using the new content type and saved it as a template.

Finally I've written C# logic to create a document library from this template and the library gets created as expected along with the correct content type, however there is no workflow being created.

Why would this be the case?

Note: If document library is created using SharePoint UI then the workflow is created and shown under the content type.


1 Answer 1


This is now resolved, after modifying my C# code I attempted to associate the workflow to my library to see if this would work and also included following line of code "workflowAssociation.AutoStartChange = true" and what I found while debugging was that I had a error on this line "Operation is not valid due to the current state of the object".

I started investigating the error and it pointed me towards IIS and how I had setup my custom service that created the library. I had initially uploaded the code to the wwwroot folder, however i moved this to "Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\WebServices" and retested and the workflow was being created as expected.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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