Friday, January 15, 2010

SharePoint 2007 Custom workflow failed to start.


I am doing some custom SharePoint 2007 Workflow development utilizing WSPBuilder and I had this one workflow that just would not run no matter what I did. I disabled all the activities in it except a Workflow History logging activity but still the workflow would not start. I am a little embarrassed to say this was driving me insane for the better part of a day.

No matter what I did when I ran the workflow I would get

1/15/2010 11:06 AM Error
System Account
Trans failed to start. 1/15/2010 11:06 AM Workflow Canceled
System Account
Workflow Trans was canceled by System Account.

I searched through the SharePoint logs over and over again and all I was seeing was unable to load workflow assembly, but I knew it would load since I had other workflows in this library and they all ran no problem.

Here is the error message out of the log file, I hope you spot the problem:

Load Workflow Assembly: System.IO.FileLoadException: Could not load file or assembly 'com.XXXX.Sharepoint.Workflows\, Version\=1.0.0.0\, Culture\=neutral\, PublicKeyToken\=$PublicKeyToken$' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) File name: 'com.XXXX.Sharepoint.Workflows\, Version\=1.0.0.0\, Culture\=neutral\, PublicKeyToken\=$PublicKeyToken$' at System.Reflection.AssemblyName.nInit(Assembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at ...

Well that part I was not seeing was PublicKeyToken\=$PublicKeyToken.
It turns out that when I created the feature using the WSPBuilder create SyncSharePointWorkflow option it must have had an error I did not notice and this error caused it not to add the PublicKeyToken to the elements.xml file. Or maybe it never did and I just forgot to update this line.

CodeBesideAssembly="com.XXXX.Sharepoint.Workflows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=$PublicKeyToken$"

Anyway once I added the correct Public Key, retracted and redeployed the workflow, it ran fine.

Hope this helps someone else save a day!!!

1 comment:

Anonymous said...

Thanks, Shaune. This fixed my (current) issue..