Welcome to MSDN Blogs Sign in | Join | Help

Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Step 4: Deploy Your Workflow

Once you have your forms and code ready to go, it’s time to compile and deploy your workflow.  To prepare for deployment:

There are two required files for workflow features:

1) Feature.xml – just like every SharePoint feature, you need one of these for high level feature information.

2) Workflow template xml file (workflow.xml) – we’ve talked about workflow templates a lot, and this is where it comes from.  Specify the aspx pages to use for your form types (for IP forms, specify our out-of-box host pages) and details about your dll, and put any extra information you need in the Metadata section. 

You’ll also need the compiled assembly and your forms.

Once you have those, you can do the actual deployment.  You will need to do the following things (if you’re using the SharePoint workflow templates, this is what the PostBuildActions batch file does):

1)      Copy the assembly to the Global Assembly Cache so that SharePoint can run it

2)      Copy your xml files and forms to the SharePoint FEATURES folder, where SharePoint features live and are installed from.  Custom aspx pages should go into the LAYOUTS folder.

3)      Call stsadm, the magic SharePoint deployment tool, with parameters installfeature and activatefeature, to make the workflow available on a site collection.

4)      Do an iisreset to refresh the assemblies and templates.

A couple more things to keep in mind:

  • Deployment for workflow goes to an entire site collection at a time
  • InfoPath forms will be installed to the server automatically during deployment if you have the <Property Key="RegisterForms" Value="*.xsn" /> tag in the feature.xml.  ASPX forms need to be copied manually to the LAYOUTS directory.

The following diagram shows how the parts of the workflow.xml map to what you’d see in the SharePoint UI and workflow forms ( = an aspx page and a hosted IP form;)):

 

Step 5: Debug Your Workflow

With the feature ready to run on your server, you can now debug it live by adding break points, attaching your Visual Studio project to the IIS (w3wp.exe) processes and clicking through the workflow.  Associate your workflow to a list and try running it.  When you find a bug, recompile, redeploy, and reset.  Repeat until satisfiedJ.

FAQ: Debugger setup woes

  • Visual Studio crashes when I “attach to process” – in the attachment dialog, only attach to Workflow or Managed Code. 
  • My breakpoints aren’t activating – be sure the dll in the GAC is the exact same one in your project.  If you change a file in your project, even without recompiling, Visual Studio will think the dll is out of date and won’t link it to the project.  Also, don’t forget to iisreset to reload a new assembly.

FAQ: Tedious debugging

Debugging can be somewhat tedious because of the deployment steps, so here is some advice to speed up the process:

·         The VS templates for SharePoint Workflow can automatically run the stsadm deployment commands for you when you build.  Just prep your xml files, sign the assembly, and set the DEPLOY parameter in the project Post Build Actions command line in your project to turn it on.

·         If you’ve only changed the assembly, just reinstall it to the GAC and call iisreset.  (no need to reinstall the feature).  The PostBuildActions.bat file in the SharePoint Workflow VS templates has a QUICK parameter that does exactly that.

·         If you’ve changed your forms or template, you’ll need to reinstall the feature.  Don’t forget to deactivate/uninstall before reactivating.

·         The <AssociateOnActivate> tag in the metadata section of the workflow.xml will automatically associate a workflow with the Document content type.  Setting this to “true” can save time setting up or reactivating an association.  Just be sure you test on a doc lib that uses the Document content type.

·         Upload a bunch of documents so that don’t have to keep cancelling workflows that error out to run them again. 

Other debugging tips:

  • Failed on Start usually means an error is happening in SharePoint before your workflow code spins up, such as not being able to find the workflow dll.  Error Occurred usually means the workflow started and the error is somewhere in the code.
  • Check the SharePoint ULS logs! – fatal workflow errors might happen outside of your workflow, so they aren’t always visible in the debugger.  Consult the logs to see if this is the case by opening the latest log and searching from the bottom up for “Workflow”.  The logs are awesome resources that often get overlooked.  Logs can be found in %Program Files%\Common Files\Microsoft Shared\web server extensions\12\LOGS.


Next time: Summary and Final Thoughts

Thanks!
Eilene

Published Thursday, November 30, 2006 9:00 AM by sptblog
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Differences in debugged workflow

Eilene -- There's great information here.  However, there are still a lot of little gotchas.  (See my blog for the ones I've managed to make it through thus far.)

A few questions ...

1) I'm observing that the workflow that I'm getting while debugging is slightly different than the one I created and installed.  For instance, a delayActivity and a codeActivity are removed.  I'm also observing that the file reference is to a dynamically generated XOML file even though the original workflow is a CS file.  Is there a way to get attached to the actual DLL?  Is there any reason why certain activities might disappear while debugging?

2) As a sort of sidebar to the preceding, I've always believed that to debug items in the GAC you had to manually copy the PDB file into the GAC alongside the DLL.  It looks like your post is saying that this isn't required.  Is that because of the specific workflow debugging type?

3) You've previously mentioned that the task from a CreateTask activity isn't committed until a workflow is dehydrated.  Other than putting a short duration delayActivity (1 second) is there a way to force a dehydration?

Rob Bogue [MVP]

Thursday, November 30, 2006 1:58 PM by rlbogue

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Eilene,

This guide is nice, but what we really need is some documentation on MSDN.

Most of the workflow actions in the Microsoft.SharePoint.WorkflowActions namespace are completely undocumented.

Ditto for the Microsoft.SharePoint.Workflow namespace.  Many of the classes don't even have a one-line description of what the heck they are for.

All the data exchange services -- IListItemService, ISharePointService, ITaskService, and IWorkflowModificationService -- completely undocumented.  There can't be any serious work on custom Sharepoint workflow actions without some visiblity into how Sharepoint idles and reawakrens workflow instances.

Heck, that's just workflows.  Half the MSDN entries in the Microsoft.Sharepoint namespace are blank as well.

Office 2007 is going live in about a month.  I hope the Sharepoint team is aware of how woeful the documentation is right now.

Thursday, November 30, 2006 2:27 PM by Cassius

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

rlbogue: "I'm observing that the workflow that I'm getting while debugging is slightly different than the one I created and installed."

I had this problem once.  I wasn't debugging, but I noticed the workflow activity log had entries from an activity which I had removed from the workflow.

After loading the new workflow DLL into the GAC, you need to call IISRESET.  By unloading the IIS process and starting a new one, you force it to map the new DLL into its memory space.

Thursday, November 30, 2006 2:32 PM by Daryl

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi Eilene,

I'm curious about the AssociateOnActivate element. There doesn't seem to be anything about this in the SDK or on the net in general. Can you give any more detail? Sounds exactly like what i'm looking for.

Thanks for these articles, they are a good practical overview.

Alex Angas.

Thursday, November 30, 2006 5:38 PM by Alex Angas

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi Rob, here are some answers for your questions:

1) Yes, Daryl is right; don't forget to iisreset to refresh everything, and make sure your build and GAC'ed dll's are the same:).  I believe the xoml is generated when it's compiled; you can actually create workflows using xoml directly instead of a cs file (haven't tried it, but I think there's a way).  The resulting dll should be the same though, in either case.

2) I'm not sure about why this is the case for workflow.  But based on my own experience, I've never copied over the pdb when debugging, which is why I didn't write anything about it;).

3) Yes, you can use OnTaskCreated to dehydrate before continuing.:)

Cassius, you're right, and thanks for the feedback!  We have more info in the RTM SDKs, and we'll be updating after that to fill in any gaps.  Sorry for the inconvenience!  For now, there's a chart with the important SharePoint.Workflow classes in the summary doc I'll be attaching to my next post, and as a rule of thumb, any On* service method puts the workflow to sleep, anything that's not plows straight through and doesn't commit until it goes to sleep.

Daryl, thanks for the helpful advice:)

Alex, the example for how this works is the out-of-box Review workflows in MOSS.  You'll notice that by default any item in a document library has Approval and Collect Feedback workflows available to run. There're not in the list of associations for the doc lib, so it's may seem like they're coming from nowhere, but in actuality, they are associated with the Document content type, which is the base type for doc lib items.  This is done with this tag:).  Just add <AssociateOnActivate>true</AssociateOnActivate> under the <Metadata> section of your workflow.xml to automatically make the workflow available on any item of the Document content type.  It'll also automatically enable new instances in the association if you uninstall and reinstall the feature (they normally get set to No New Instances on deactivation).

Friday, December 01, 2006 3:19 AM by Eilene Hao

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Eilene --

I have a batch file that does the install (because I'm still copying in the PDB.)  It's tearing down and rebuilding the stack -- complete with two IISRESETs.  Yea, I know overkill, however, I don't want to take chances.  

I rebooted the whole system and I got an accurate instance.  ... Now all I have to do is figure out why the workflow won't rehydrate after a delay.  I feel like the salmon swimming up stream (only to be snatched up by a bear at some point.)

Rob

Friday, December 01, 2006 9:36 PM by rlbogue

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

rlbogue: "I have a batch file that does the install (because I'm still copying in the PDB.)  It's tearing down and rebuilding the stack -- complete with two IISRESETs..  I rebooted the whole system and I got an accurate instance."

I sometimes wonder if the OWSTIMER.EXE process should be restarted as well when you replace a workflow DLL.  I know this is sometimes the process responsible for (trying to) rehydrate workflow instances.  Then again, it might just be telling Sharepoint to do it through a webservice or some such.

rlbogue: "Now all I have to do is figure out why the workflow won't rehydrate after a delay."

You're not the only one.  Lots of people have this problem, and I've never heard anything from Microsoft about it.  I had this problem back in Betas 2 and 2TR.  Loads of people talk about it on microsoft.public.sharepoint.development_and_programming, but I've never seen a Microsoft employee post there.  For all I know, they don't even read the newsgroup, which seems strange to me.

Eilene is helpful; maybe she'll shed some light on what's happening with selays.

Since installing the RTM release, my delays started returning.  For some reason, they never rehydrate on the first "Workflow" timer job.  Always on the second run, 6-10 minutes after the delay expires.

Knock on wood they're working for me right now.  Lots of people still can't get DelayActivity's to return at all in Sharepoint, which makes the majority of real-life workflow scenarios impossible.  :(

Friday, December 01, 2006 10:34 PM by Daryl

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi guys, there's a bug on delays at the moment; we're working on a patch that's almost ready.  Sorry for the inconvenience.

Sunday, December 03, 2006 4:39 AM by Eilene Hao

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Eilene,

Great to hear.  Bugs will happen.  Developers just want to know that 1. MS knows the bug exists, and 2. it will eventually get fixed.

Sunday, December 03, 2006 3:17 PM by Daryl

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Daryl--

The PSS folks are under water right now trying to stay in the newsgroups and as you can see some of the MVPs are struggling with keeping ahead of the demand.  It should get better after the first of the year.

Rob

Monday, December 04, 2006 7:29 AM by rlbogue

# OnePage Workflow in SharePoint 2007

OnePage : der einfache Blick auf das Wesentliche - die wichtigsten Informationen zu einem Thema auf einer

Tuesday, December 05, 2006 2:40 PM by SharePoint, SharePoint and stuff

# Creating Workflows with Visual Studio 2005 (Walkthrough)

Im not sure how many have found this yet but Eileen Hao has put together a Seven Part walkthrough with...

Thursday, December 07, 2006 12:25 PM by Bob Fox's Sharepoint Blog

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hey, could any one please tell me why I am not able to see the PostBuildActions.bat file when I am creating a Workflow library?  Also please let me know how to create it.

Thanks in advance

Wednesday, December 13, 2006 3:51 AM by Abhinandan

# WF inside of SharePoint

I'm a little late to notice this, but Eilene Hao, a PM on the SharePoint Workflow team, has put together

Wednesday, December 13, 2006 4:51 PM by Matt W's Windows Workflow Place

# SharePoint 2007 workflow development

Encontrei esta compila&ccedil;&atilde;o interessante de recursos sobre desenvolvimento de workflows para

Saturday, December 16, 2006 8:24 PM by Miguel Isidoro

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Sorry about that, postbuildactions.bat is coming out with the RTM MOSS SDK, which is alllmost ready...

Monday, December 18, 2006 10:21 PM by Eilene Hao

# The GAC

Hi,

Perhaps I'm slow but I still don't get the relationship between the debugger and the GAC.  Should the pdb be copied?  If so how does one get the location? If not, why are breakpoints sometimes dissabled even after uploading the dll and resetting iis?  Why do some dlls in the gac appear in windows\assembly\gac and others don't?  Is there a bug in visual studio relating to this?  Is there an article that explains this well and in simple terms, I'm tired of reading contradictory threads.

VJ

Wednesday, February 21, 2007 3:39 AM by VJ

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Eilene,

Can we deploy a workflow as feature using the markup language (.xoml)

Liz

Monday, March 05, 2007 4:59 AM by elizageojy

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi,

       delay activity bug issue yet fixed or not? I've installed RTM MOSS SDK. whenever my workflow hits delay activity it goes to sleep and never wakes up again.

any comment really appreciated!

Tuesday, March 27, 2007 5:51 AM by luckshika

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi Eilene,

when I want to used my deployed custom workflow I get "the form has been closed" do you know why I get this error.

I have been stuck for too long now, please help.

thanks

Isabelle

Wednesday, April 04, 2007 3:40 PM by Isabelle

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi Eilene,

I just found the solution to the error "the form has been closed". In the workflow.xml in the MetaData section when I specified the FormURN of my Initiation Form it was wrong even if I copied and paste the Form ID in the InfoPath properties. It was urn:schemas-microsoft-com:office:infopath:Initform:-myXSD-2007-03-08T01-00-06

instead of

urn:schemas-microsoft-com:office:infopath:InitiationForm:-myXSD-2007-03-08T01-00-06

the name of the form was missed spelled.

Isabelle

Thursday, April 05, 2007 9:25 AM by Isabelle

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi,

The sample workflow that Ive developed opens the Initiation form in Add workflow settings(List->Tasks->WorkflowSettings).

Is there a way where I get this form to open up when I click on Task->NewItem because instead of using the standard task new item details..i want to use the info path(Inititationform.xsn) to do this. Would this be possible.

Also, when I create a new item in tasks,the workflow triggers off but it shows 'Failed on start' in the log the error'The event receiver for the context is invalid'

Any feedback on this will help

Sunday, April 08, 2007 9:31 PM by Don

# Start Learning Workflows!!

Wow such an exciting topic to learn!! its nice and fun yet its a bit difficult to grasp easily,,, This

Thursday, April 12, 2007 9:46 AM by Code Eater

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi all,

Would anyone know why my workflow errors out with "Failed on Start".  When I check the logs, it says it can't find my dll or one of its dependencies.  I've loaded it to the GAC but don't know what else needs to be done for it to be found.  This is a custom wf I built from an example, it uses an InfoPath Initiation form, accepts my text, then I contine the wf by submitting.  At that point it should use my dll in the GAC, but it can't locate it.  I verified that it's signed, version number, public key token - all correct.

Thanks for any help,

Kevin

Thursday, April 26, 2007 10:27 AM by Kevin S

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

After doing all the steps when i do rebuild I am not able to see the PostBuildActions.bat file when I am creating a Workflow library?  Also please let me know how to create it.

Monday, May 07, 2007 10:27 AM by Suneetha.n

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Suneetha.n : You need the SharePoint workflow templates for Visual Studio.  Those templates install when you install the SharePoint 2007 SDK.

Here's the link:

http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&displaylang=en

Tuesday, May 15, 2007 2:17 PM by roky

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi i am getting "Error occured" when i try to attach my custom workflow to the document library item.any clues?

Wednesday, May 30, 2007 8:21 AM by Shashwat

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

when i uploading a document,my workflow is showing the status as "falied on start(retrying)".

Thursday, June 07, 2007 10:10 AM by revati

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

I've got the same error "failed on start(retrying)". In log it says that something wrong with the context of workflow.

It seems that in VS workflow designer you can't set WorkflowId property of onWorkflowActivated activity. (This property simply is absent in the "Properties" window). But in ECM Starter Kit workflows this property was set (saw in *.Designer.cs file) and they work fine.

Is it cause of error? Is it bug?

Tuesday, August 07, 2007 4:00 AM by totmakov

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

When I start this sample workflow, I got errors like 'Workflow [myworkflowname] was canceled by System Account' and 'Failed on start'.

How can I fix these errors?

Monday, August 13, 2007 12:12 AM by Min

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

When I want to use my deployed custom workflow I get "the form has been closed" does anyone know why I get this error.

I have been stuck for too long now, please help.

Thanks,

Laxmikant

Thursday, September 06, 2007 6:42 AM by Laxmikant

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Great. "Failed on Start (retrying)" an NO solution! Does Ms have a clue?

Tuesday, October 09, 2007 12:38 PM by Thor

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

use Sharepoint Logging Spy for real time diagnostics to resolve these issues.

Sunday, January 27, 2008 6:46 PM by Stiow

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi I am new to WF. I just created a new custom activity using VS. It built succefully but when I run it, I am getting the message "Unable to start program 'C:\Workflows\SendEmailC\bin\Debug\SendEmailC.dll". Would any one assist me in this problem?

Regards..

Wednesday, February 13, 2008 6:49 AM by Asif

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Hi

I have created two Workflows for a site

1)A seperate Approval Group of the site who approves the Workflow ,whenever it is started.And it is working fine.

2)when i enable my second workflow(which is the Member Approval(the member group approves the document) for the same site, and start the workflow i got the error in sharepoint itself stating "An error has occured while starting the [Workflow name]".

it will be of great help ,if you can provide me some soln to this problem i am facing for sometime now..!:-(

Regards

Vimal raj

Monday, February 18, 2008 10:28 AM by Vimal Raj SG

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

Would anyone know why my workflow errors out with "Failed on Start".  When I check the logs, it says it can't find my dll or one of its dependencies.  I've loaded it to the GAC but don't know what else needs to be done for it to be found.  This is a custom wf I built from an example, it uses an InfoPath Initiation form, accepts my text, then I contine the wf by submitting.  At that point it should use my dll in the GAC, but it can't locate it.  I verified that it's signed, version number, public key token - all correct.

Monday, March 03, 2008 1:03 AM by suryakant

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

I was able to get rid of the Failed on Start error by repairing the .NET Framework 3.0 SP1. I put additional details in this blob post:

http://www.thesug.org/blogs/annw/Lists/Posts/ViewPost.aspx?ID=6

Sunday, March 30, 2008 3:57 PM by Ann

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

I've found one cause to workflows failing on start. When/If you create a new task in your workflow, make sure you set your TaskID equal to a new GUID. This is easy to miss if you bind your TaskID property from the CreateTask activity, rather than specifying a hard coded Guid for the TaskID. On your handler for the CreateTask activity, put code in place that sets the variable that you bound against.. something like "taskID = Guid.NewGuid()".

Wednesday, April 30, 2008 1:28 PM by Seth Hildebrand

# Problem on edit SPFile properties from a workflow.

Hi,

I've tried to create simple sequential workflow in VS 2008. Everything works fine except I can't edit any property of the SPFile from the workflow. No exceptions fired, no messages in a log.

Are there any ideas what the problem could be. Thanks much!

Yuriy.

Monday, June 09, 2008 4:38 AM by yfrolov

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

I have a problem where it appears the workflow starts before the file is complete in a document library.  I have a scheduled task that copies an XML file from a remote system via the WebClient.  When my workflow starts it loads the XML into an XMLDocument object via workflowProperties.Item.File.  But it gives me an error "root element is missing".  When I manually upload the same file it works.  I added a Thread.Sleep(30000) method to my code just before loading the file as a work around, but is there a better way to tell if the file has finished loading?  

Wednesday, June 11, 2008 8:21 AM by halomez

# re: Developing Workflows in VS: Part 6 - Deploy and Debug your workflow

I have a workflow developed and deployed on the production site.Due to the change request we had to change the workflow by adding a number of states and event driven activities when i deploy the changed workflow with the same dll name i have seen that the already existing items on the production site which were In progress dead and not moving forward where as the new items where using the new version of the dll.Is there any way that i can force the older items In Progress to use the new version of the workflow.

Thanks in advance

Monday, July 14, 2008 2:20 AM by Chandra

# 应用SharePoint的Workflow须记住的10句话!

1)SharePoint的工作流是基于文档的工作流,只能关联到列表,文档库和内容类型上 2)SharePoint的工作流模板利用网站功能(Feature)来发布 3)SharePoint的...

Tuesday, September 23, 2008 11:14 PM by 晃晃悠悠

# 微软sharepoint产品组博客——使用VS进行工作流开发系列博客

最近的两个月一直在研究SharePoint的内容,从配置到开发,从配置,到sharepoint对象模型,webpart,eventhandler,workflow,contenttype,自定义字段...

Monday, November 24, 2008 12:36 AM by virus

# 使用VS进行工作流开发系列博客7-Developing Workflows in VS: Part6 - Deploy and Debug your workflow

在VS中开发工作流:部署和调试工作流原文地址:http://blogs.msdn.com/sharepoint/archive/2006/11/30/developing-workflows-in-v...

Monday, November 24, 2008 10:28 PM by virus

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker