SharePoint Workflow feature in VS 2008 (Part II)


I will continue from my last post on authoring SharePoint workflows in VS 2008 by providing a walkthrough.


In order to work with SharePoint workflows in VS you will have to setup your development machine as follows:


1)    Install Windows Server 2003.
2)    Install Internet Information Services (IIS). (In Control Panel, Add/Remove Windows Components, Application Server, Details, Internet Information Services (IIS).)
3)    Install .NET Framework 2.0 and.NET Framework 3.0.
4)    Enable ASP.NET 2.0.5727 in IIS Manager.
5)    Install Microsoft Office SharePoint Server 2007 (MOSS). Make sure to run the configuration wizard. [Edit: May 29: WSS is not supported]
6)    Install Visual Studio 2008. Use the default installation, or make sure that Visual Studio Tools for Office is selected on the Custom installation page of the Setup wizard.

Some questions that come to mind -  Firstly, why only Windows Server 2003 (no Windows Xp)? Well MOSS/WSS can only be installed on a Windows Server machine. And secondly, why does MOSS/WSS need to be installed on the development machine? It's just required to do any (not just workflow) practical SharePoint development since you have to do an iisreset, access the GAC etc.

Is the above installation order important? Yes and no. If you install SharePoint before Visual Studio, your toolbox for Workflow development comes initialized with all SharePoint related activities. So it is a good idea to install in that order. If you do not do so - you will have to reset your toolbox (Right click on the toolbox and select 'Reset toolbox') once you start developing SharePoint workflows.

Project Creation - Select the 'SharePoint 2007 Sequential Workflow'

NewProjectWizard


New SharePoint Workflow wizard: A wizard shows up that allows you to specify the parameters for debugging - the name of the worklfow, the local SharePoint site (no support for remote SharePoint sites) on which to deploy the workflows, the list to associate it with, the task and history list to work with. Also you can specify, how you intend to start your workflow on F5. 


Wizard1


Select the parameters for workflow association on F5:


wizard2


Wizard3


 


Workflow designer:On pressing 'Finish' in the wizard, the workflow designer shows up.


designer


Property Window:A few additions to note include a property window that allows you to view/change the selections you made in the wizard. The property window is visible when you have the project node selected in the Solution Explorer.


PropertyGrid


 


Breakpoint: You can go ahead an now put a breakpoint in the workflow activity in the designer, by right clicking the activity and selecting 'Insert breakpoint' from the context menu.


breakpoint


 


Press F5 now to start debugging  and you will notice the output window shows all the deployment details - Install the assembly to the GAC, restart IIS, copy workflow.xml, feature.xml, and any other resource files/InfoPath forms you may have, install and activate the workflow template as a feature in SharePoint, associate the workflow with the list you specified in the wizard.


OutputWindow


In the browser window that launches you will see the deployed workflow.


DeployedWorkflow


After you manually start the instance of the workflow, you will see the breakpoint being hit:


breakpointHit 


Btw. my technorati profile is getting started here: Technorati Profile.

Comments (44)

  1. People have already started blogging about the workflow creation with VS 2008. Here are a couple of cool

  2. snowcounty says:

    Before VS 2008, typical code-build-debug cycle would be: Write the code Build the workflow project. Copy

  3. andyd273 says:

    So, I want to make a workflow, but the development machine (Or the machine that I do all the programming/development on) is my computer, which has Windows XP Pro and does not have sharepoint installed on it. Our intranet server does have Windows Server 2003 and Sharepoint, but it is just a blade in the (very cold) server room.

    Is it possible to create a workflow like you outline without working on the actual intranet server?

    I'd really like to be able to use my nice warm office, with my big computer monitors to do this.

  4. SergeyL says:

    andyd273, Use Remote Desktop.

  5. Andy says:

    When I hit F5 to start debugging, I get the following error:

    ------ Deploy started: Project: DocumentApproval, Configuration: Debug Any CPU ------

    Successfully installed this assembly into the global assembly cache: DocumentApproval.dll.

    Successfully restarted Internet Information Services (IIS).

    Successfully copied workflow.xml to C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12TEMPLATEFEATURESDocumentApprovalworkflow.xml.

    Successfully copied feature.xml to C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12TEMPLATEFEATURESDocumentApprovalfeature.xml.

    Failed to install the workflow template to Microsoft Office SharePoint Server.

    Access denied.

    Failed to deploy the workflow template to Microsoft Office SharePoint Server.

    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

    Why is 'Access Denied'? What am I doing wrong? My account has full administrative rights on the box, in sql, in moss, etc.

  6. Andy,

    From what it looks like, you do not have permissions on the SharePoint server to install a feature. Can you please check the SharePoint logs in %PROGRAMFILES%Common FilesMicrosoft Sharedweb server extensions12LOGS  for more details on the error. Also, ensure that you are a "Site Collection Administrator" in SharePoint.

    Let me know if this works for you.

    Thanks,

    Nikhil

  7. DoubtingSharePoint says:

    So, either i need to purchase Windows 2003 Server license for all the developer machine, or i need to install VS2008 on the server and let my 3 developers to remote into the server just to do workflow ?? Are you really serious?

  8. Unfortunately, we don't have a better answer than that - since SharePoint is not supported on Client OS. And doing remote development is ticky from a client OS (More on this over here: http://msdn2.microsoft.com/en-us/library/bb530302.aspx). I have noticed that a number of SharePoint  developers using Virtual PCs on a Client OS to do their development. I would recommend using that if you can.

    This is also a good guide to machine setup for SharePoint development: http://weblogs.asp.net/erobillard/archive/2007/02/23/build-a-sharepoint-development-machine.aspx.

    Hope this helps!

    -Nikhil

  9. Joe says:

    Will Visual Studio Tools for Office ever be available for download for Visual Studio 2008 Standard? I really want this functionality for a WSS 3.0 site to build workflows but it's only available for VS 2005 or VS 2008 Pro and later.

  10. Joe,

    AFAIK these features are only going to be available in VS 2008 Pro and up.

    Thanks,

    Nikhil

  11. Ven says:

    So can we not create Sharepoint workflow projects in VS2008 on a development box which doesn't have SharePoint installed.

    Our usual way of MOSS development is we use Virtual PCs as our sharepoint dev servers and we just use VS2008 (And other add-ins as necessary) for development.  Is there a way we can successfully create VS2008 workflow projects on a development machine which doesn't have sharepoint installed?

    Thanks,

    Ven

  12. basma says:

    well i want to use infopath form in my workflow but i don't know how to deploy it with VS2008,can u help me,

    thank u

  13. jj_the_skeptic@hotmail.com says:

    I've been working on a workflow for a few weeks now and I have to say that debugging a workflow with VS2008 is often very clunky/quirky.  Sometimes my breakpoints aren't hit.  Sometimes when the breakpoint is hit, the debugger will bring up an older workflow diagram - missing shapes that are in the project one I just deployed.

    Some exceptions occur but the debugger doesn't catch them - the workflow just ends and I'm left looking through the SharePoint trace logs trying to find out why.

    This is still better than with VS2005 - automated deployment of the feature and the ability to debug into the code (even if inconsistent)

  14. Sam says:

    I have a develpment server running wss 3.0 and vs 2008 pro and I have the following message when building a project from the sharepoint templates:

    ------ Build started: Project: SharePointWorkflow4, Configuration: Debug Any CPU ------

    C:WINDOWSMicrosoft.NETFrameworkv3.5Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Office.Workflow.Tasks". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

    C:WINDOWSMicrosoft.NETFrameworkv3.5Vbc.exe /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Diagnostics,System.Linq,System.Xml.Linq,System.ComponentModel,System.ComponentModel.Design,System.Workflow.ComponentModel.Compiler,System.Workflow.ComponentModel.Serialization,System.Workflow.ComponentModel,System.Workflow.ComponentModel.Design,System.Workflow.Activities,System.Workflow.Activities.Rules,System.Workflow.Runtime,System.Workflow.Runtime.Hosting,Microsoft.Office.Workflow.Utility,Microsoft.SharePoint,Microsoft.SharePoint.Workflow,Microsoft.SharePoint.WorkflowActions /optioncompare:Binary /optionexplicit+ /optionstrict- /optioninfer+ /rootnamespace:SharePointWorkflow4 /doc:objDebugSharePointWorkflow4.xml /define:"CONFIG="Debug",DEBUG=-1,TRACE=-1,PLATFORM="AnyCPU"" /reference:"C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIMicrosoft.SharePoint.dll","C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIMicrosoft.SharePoint.Search.dll","C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIMicrosoft.SharePoint.WorkflowActions.dll","C:Program FilesReference AssembliesMicrosoftFrameworkv3.5System.Core.dll","C:Program FilesReference AssembliesMicrosoftFrameworkv3.5System.Data.DataSetExtensions.dll",C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Data.dll,C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.dll,"C:Program FilesReference AssembliesMicrosoftFrameworkv3.0System.Workflow.Activities.dll","C:Program FilesReference AssembliesMicrosoftFrameworkv3.0System.Workflow.ComponentModel.dll","C:Program FilesReference AssembliesMicrosoftFrameworkv3.0System.Workflow.Runtime.dll",C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Xml.dll,"C:Program FilesReference AssembliesMicrosoftFrameworkv3.5System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /keyfile:key.snk /out:objDebugSharePointWorkflow4.dll /target:library "My ProjectAssemblyInfo.vb" Workflow1.vb Workflow1.designer.vb "My ProjectSettings.Designer.vb" "C:Documents and SettingsupdiksbLocal SettingsTemp_wp46f6r.vb"

    vbc : warning BC40057: Namespace or type specified in the project-level Imports 'Microsoft.Office.Workflow.Utility' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

    SharePointWorkflow4 -> C:Documents and SettingsupdiksbMy DocumentsVisual Studio 2008ProjectsSharePointWorkflow4SharePointWorkflow4binDebugSharePointWorkflow4.dll

    Done building project "SharePointWorkflow4.vbproj".

    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

    Also if I try to deploy, I get the following error:

    Feature 'ed6f8fba-4bea-415c-ac31-ce5daa6cfa96' could not be installed because the loading of event receiver assembly "Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" failed: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

    File name: 'Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

      at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

      at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

      at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

      at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

      at System.Reflection.Assembly.Load(String assemblyString)

      at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

    I noticed that there are references to the Microsoft.Office.WHATEVER assemblies & namespace but that isn't installed on my server (isn't that only installed with the full version of Sharepoint server - not WSS?)

  15. I have lots of good tips on SharePoint Workflow (based on MOSS 2007, not WSS) at the above link.  Most were discovered the painful way while writing a 10,000 line custom workflow in C# under VS 2005.  I hope to convert it to VS 2008 once Service Pack 1 is out of beta.

  16. PurpleKateToo says:

    I am getting the same compilation/deployment issues as Sam (who posted above). My assumption is that Microsoft.Office.Workflow.Feature is actuall  installed with the MOSS SDK. So like Sam I don't have MOSS, just wss, so should I install the MOSS SDK? Will this work without MOSS?

  17. Johan Pretorius says:

    On the post by Nikhil:

    Nikhil, you propose that every developer either install Windows 2003 server or remote desktop into the server. Have you noticed that in the first link in your post the official microsoft documentation states that the best practice way to develop is for developers to work on a non server OS like XP and then deploy to the server.

    And yet you say this is impossible......  Something does not add up here.

    *************************

    Unfortunately, we don't have a better answer than that - since SharePoint is not supported on Client OS. And doing remote development is ticky from a client OS (More on this over here: http://msdn2.microsoft.com/en-us/library/bb530302.aspx). I have noticed that a number of SharePoint  developers using Virtual PCs on a Client OS to do their development. I would recommend using that if you can.

    This is also a good guide to machine setup for SharePoint development: http://weblogs.asp.net/erobillard/archive/2007/02/23/build-a-sharepoint-development-machine.aspx.

    Hope this helps!

    -Nikhil

    ***************************************

  18. Hi PurpleKateToo, Sam,

    VS 2008 workflow integration is only supported on MOSS.

    To get it to work on WSS there is a workaround. Remove the reference to Microsoft.Office.Workflow.Tasks from project assembly references. This assembly is only available in the MOSS version of SharePoint and will not be resolved on a machine with WSS installed.

    Also, open the feature.xml in the project and remove the ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" and

    ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver. This feature receiver is required for MOSS related functionality (InfoPath forms) and should not affect your WSS workflow development.

    Hope this helps!

    -Nikhil

  19. Johan,

    Which link are you talking about here?

    "Have you noticed that in the first link in your post the official microsoft documentation states that the best practice way to develop is for developers to work on a non server OS like XP and then deploy to the server."

    -Nikhil

  20. PurpleKateToo says:

    Hi Nikhil,

    I have been tinkering over the weekend, and discovering that by doing just what you suggested, I have managed to create a working Sequential workflow. I am now trying to do the same with a State Machine workflow. Thanks for your help, its good to know that I don't need MOSS, which would be overkill for my organisation.

    - Kate

  21. Jason says:

    This is a great bost, but like almost every other post out there from various people, it's incomplete.  These walk-thrus are awesome, but they always just stop abruptly and never show a full, end-to-end instruction...so people like me are left to try to piece things together from all over.  Every blog on this topic shows a different way of doing the same thing.  No standards, no best practices, just smart people who are close enough to the product to figure out their own personal workarounds for things that are not officially documented anywhere.  Sorry, it's just so frustrating how MS has thrown a product on the market and provided little to no information on how to make it work.

  22. Vaibhav says:

    As mentioned I installed the VS 2008 on the Win Server 2003 machine which already have MOSS 2007 installed.

    Now when I try to create the new project and give the URL on my site I get the error "SharePoint Server not installed. Please run the Microsoft Office SharePoint Server 2007 setup."

    Just to let you know that I have a MOSS setup scaled on 3 Servers, Application Server, Web Server and DB Server. And I have installed VS2008 on Application server.

    Please suggest the solution.

  23. We do not support development on a farm topology. Please install MOSS with single server installs for it to work.

    Thanks,

    Nikhil

  24. Vaibhav says:

    Oh ok, I absolutely didn't find this thing anywhere that vs2008 doesn't support the development on MOSS if it is scaled on farm topology. Thanks.

    here are few things i would require ur help on.

    - Can u direct me some link where I can get more information related to vs2008 can be used on farm tolopogy.

    - What is the alternate solution I have to do the development mostly workflows for MOSS 2007.

    Thanks again.

    -Vaibhav

  25. I've seen several comments on running SharePoint on a server. There is actually a way to run SharePoint (and develop workflows) on a Vista PC. Not supported, but it works. I'm doing it and it works fine. See the link above.

    Thanks,

    Jesper

  26. carl says:

    Hello,

    I didn't see this anywhere in the post.  I developed a workflow as stated above using VS 2008.  Once I get the workflow working correctly, how do I deploy it to my production environment?  Is there a built in way to change where it is deployed to?

  27. Raj says:

    HI,

    Why dont you provide complete details of creating  simple workflows using Visual studio 2008-- i mean to say a complete details like  using few tools to present a meaningful workflow or refer some links for the same

  28. Priyanka says:

    Hi Nikhil,

    I have a workflow, which debugs and deploys fine on my development environment. And after I deployed it on production it was fine till then. I wanted to debug some error which I could not see on my development. so I took my code to the production for debugging. But my workflow doesn't deploy at all. It gives me the following error:

    Successfully installed the workflow template to Microsoft Office SharePoint Server.

    Failed to associate this workflow template with a Microsoft Office SharePoint list. Object reference not set to an instance of an object.

    Failed to deploy the workflow template to Microsoft Office SharePoint Server.

    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

    I am using an account which has site collection admin rights. Plus I have tried uninstalling-deactivating reinstalling-reactivating several times but to no avail. In fact then created a new workflow on production and tried deploying it. But it gives me the same error.

    Would be thankful to any help.

  29. Here the problem might be that we store the data for a particular SharePoint install - the list to associate with etc. It seems like since you have moved the project across computers now the data is not relevant any more and you might have to run the workflow debug wizard again to populate fresh data.

    Right-click the project in the solution explore and select "Workflow debug settings.." run through the wizard.

    See if that helps.

    -Nikhil

  30. Mash says:

    Hey Nikhil,,Gr8 Start Up blog,,

    Can you please provide some reference to the design the State Machine workflows in VS2008,,I tried on my own but struck up at deploying them coz of issuesin the way i'm assigning the activity owner ,,correlation tokens and its Task properties

    Would reallya ppreciate if you can point to some gud reference material

  31. kedar031 says:

    hi nikhil,

                I have similar issues as with PurpleKateToo.

    I am developing a custom workflow for WSS 3.0. with VS 2008. I removed the referenced assemblies and also the receiver assemblies and receiver class from feature.xml as u suggested.

               Still my issue is not fixed. When i start the workflow it says.,

    "FAILED TO START". Am bugging around it since two days.. plz help

    -Kedar

  32. Hi Kedar,

    Have you checked the SharePoint logs at %Program files%Common FilesMicrosoft SharedWeb Server Extensions12LOGS. You should see why it is failing to start.

    -Nikhil

  33. svenkat.net26 says:

    Hi,

            I am preparing workflows but here not available the microsoft office and I am using MOSS 2007 standard edition, so how can I produced the form to the client system.  There is any chances to produce a form instead of IP form, Document form.

    Thanks and Regards

    Venkatesh

  34. Bob says:

    Hi Nikhil,

    I am totally stuck without any clue as to how to start developing custom workflows with VS 2008. My dev environment is on Vista and I do not have a sharepoint server installed on my local machine. The only server I have is our company level server and I have a site setup on that server.

    All the walkthrough I see require that I have the sharepoint dlls available on my local machine. I can't get those dlls from the server box because it is centrally administered and is at our corporate level.

    So,

    1. Where can I download these dlls from?

    2. Can I give the URL of my sharepoint site running on a remote machine in the initial workflow wizard step?

    3. I don't see the sharepoint activities in my toolbar. I guess this is because I dont have reference to those dlls.

    Please help me

  35. Unfortunately, remote development of SharePoint workflow solutions is not supported. The SharePoint Dlls are not distributed on their own and hence, you will not be able to download them from anywhere.

    Your best bet is to setup a VPC for SharePoint development with server and VS installed on it.

    There are a couple of reasons why remote deployment is not supported for workflows. Deployment of workflows requires an IIS application pool reset every time a new version of the worklfow is deployed. The shared server cannot be used anything for development then and that completely mitigates any benefits of going remote. Also, you would require admin rights on the shared server to deploy workflows.

    This is why we do not support working against a remote machine.

  36. Bob says:

    Nikhil,

    You rock!  Thanks a lot for your quick response.

    I have a few more questions 🙂

    1. Can I deploy the workflows developed on my local machine on our centralized sever without being an admin on that box? Eg: I can easily deploy the workflows I develop using sharepoint designer just by giving the path of my remote site and then running thru the wizard.

    We actually want to know if we should go ahead with it because it's quite difficult for us to get anything done through the admins because of the bureaucratic procedures involved in it 🙁

    2. Does deploying any sharepoint workflow (after development) involve deploying a dll on the remote server's GAC too?

    3. We basically need to have our own custom forms for approval workflows. So can we use infopath forms as workflow task edit forms in sharepoint designer? I am asking this because we still guess we will not be able to use VS 2008/2005 because of the limitations we have.

    Thanks again!

  37. Bob says:

    Nikhil,

    In addition to the questions I have asked, I am a bit inquisitive about the way custom workflows work in sharepoint designer without having to manually access the remote server for deployment. We don't need to install any assembly or reset ISS in the case deploying a workflow created using sharepoint designer. How is this achieved??!

  38. Sorry for the late response.

    SharePoint designer workflows are declarative (XML based) and hence, require lesser permissions to deploy and work across a remote setup. They support ASP.NET based forums that can be used to accept data.

    You can find more details here: http://msdn.microsoft.com/en-us/library/ms414204.aspx

  39. number7 says:

    Hello!

    I'm very new to working with WF.

    Is there other option that I can develope WF without a server OS?

    I'm a contact developer, & I'm working with a client.  They out-sourced their IT to someone else.  Due to some company policy, they're not allow to let work on my development directly on any server(s) (inclucding VPC).  There's no other way I can make them to change their mind.

    So, this is what I'm thinking & not too sure if this will work for me.

    I'm thinking if I just install the free copy of SharePoint to my development PC (XP-Pro), then create a WF project from my XP-Pro pc, then deploy to my client or give their IT company a copy of the deployment.  Will this work?  please verify & provide the links to help me to make this happen.

    Thank you!

  40. chris says:

    hi nikhil,

    another one with a deployment problem 🙂

    i developed 2 workflows with vs2008, packed into a solution and try to deploy to a wss.

    i removed the receiverassembly and receiverclass tags from the feature xmls and removed the reference to Microsoft.Office.Workflow.Tasks from the project.

    solution deployment was ok, no errors, i see the features available and can active them and attach them to lists.

    but when i try to run the workflows, sharepoint doesnt start them. i don't even have a error message, the workflow status column stays blank, there is no error message in 12/logs/, nothing.

    after trying your mentioned hints without success, i'm pretty clueless what to do.

    thanks in advance,

    chris

  41. chris says:

    ok i get it.

    also remove the TaskListContentTypeId attribut from elements.xml to make it work in wss

Skip to main content