"Leading the way in SharePoint Solutions"

Chris Mann

Issues with WSPBuilder and a .Net 3.5 state machine workflow with a declarative rule 

Tags: .NET 3.5, Workflow, WSPBuilder, SharePoint

Its a long title, but its the combination of these three things that caused me a headache for hours.  The first thing I noticed was that after I added a .rules file, I could no longer build using by using right clicking the project and choosing build.  Instead, I had to use the WSPBuilder –> Build WSP option otherwise I would get the below build error.
 
Resource identifier <type name> has already been used in this assembly. 
 
I Googled around a bit, and it looked like there was some issue with WSPBuilder and having both a .rules and .layout file in a workflow.  So I (begrudgingly) deleted the layouts file and it built and deployed OK.
 
After I deployed the workflow, I kept getting Failed on Start (retrying) when trying to start the workflow.  While debugging, it would run the constructor and the InitializeComponent() calls OK, but then would just stop with no exception and the workflow activation properties would never get correctly initialized.  I looked in the ULS logs and saw:
 
System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation.
 
So my first thought was that I had incorrectly set a correlation token or something like that, but after double and triple checking my design, I resorted back to Google and came upon these two posts.
 
 
 
Which suggest to import the WWF 3.5 build targets to your VS project file.  Easy enough:
 
  1. Right click the project and choose Unload Project
  2. Right click the unloaded project, and choose Edit.
  3. Scroll down until you see 
    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  4. Add this line:
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets" />
  5. Save the file, right click the project file in Solution Explorer, and Reload the Project.

 

Built and deployed the workflow and everything was as it should be.   This also took care of the issue with having to delete the .layouts file.

 
Posted by Christopher Mann on 23-Feb-10
191 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Comments

Name:
URL:
Email:
Comments: