Well that was an interesting few hours this afternoon following Nick’s article on creating workflow within Visual Studio 2005 for SharePoint. I got as far as creating all the InfoPath structures, and then when I went to edit the workflow.cs in Workflow Designer, I was faced with a Class Script and Nick had a pretty picture?.. hmm what went wrong..
Well the key difference is that Nick is developing his workflows on a Virtual machine that has Visual Studio and SharePoint installed.. I don’t.. even though I have the .Net 3.0 foundation and everything else loaded, I don’t have some of the key DLL’s that are needed..
How does this manifest itself I hear you say.. Well it’s not that obvious whats wrong, other than the fact that you don’t get the pretty workflow designer window and the relevant tools. There is however 3 Warnings in the error window stating that “The referenced component ‘Microsoft.SharePoint’ could not be found” , this is also joined by entries for Microsoft.SharePoint.WorkflowActions and Microsoft.Office.Workflow.Tasks.
The resolution for this is to copy the relevant files from a server with these assemblies already installed and then registering them in your global assembly cache (GAC).
Firstly, if you don’t have this created, create the following directory on the machine with Visual Studio 2005 loaded on it..
c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI
Now, from the same location in the SharePoint servers 12 Hive, copy the following files into that location:-
Microsoft.SharePoint.dll
Microsoft.SharePoint.Security.dll
microsoft.sharepoint.WorkflowActions.dll
microsoft.office.workflow.tasks.dll
This resolves the issue with the references and permits the project to open properly without errors, but now, if you double click on the workflow.cs entry you get the following error:-
Could not load file or assembly ‘Microsoft.SharePoint.WorkflowActions.intl, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
To the same location as before, now copy the following 2 files from the SharePoint server:-
c:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions.intl\12.0.0
.0__71e9bce111e9429c\microsoft.sharepoint.WorkflowActions.intl.dll
c:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions.intl.resour
ces\12.0.0.0__71e9bce111e9429c\microsoft.SharePoint.workflowactions.intl.reso
urces.dll
(You’ll have to cut and paste the above into notepad and remove the carriage returns as they wouldn’t paste into the blog properly for some reason..)
Now the last part.. Open an explorer window on your development to the folder you just created, and open a second to c:\windows\assembly
Now drag all 6 files from the ISAPI folder and drop them onto the C:\windows\assembly folder to register them with the GAC. (Note, the files won’t copy, it’ll just create the references you need..)
Now run VS2005 once more and start workflowing to your hearts content..
Many thanks to Gudjon who was the key source for that fix..