Skip to main content

Introduction

image VS. image

If you are working in a workflow foundation project you may find you have created a class library (see image below) and want to put workflow activities into it but you may have issues with that because you didn’t create a Workflow activity library.

Issues

Some of the issues you may find are the add item menu doesn’t have the options you expect and the workflow designer interface doesn’t work.

image VS. image

Solution

To solve this you need to modify the class library project file very slightly. To do that simply open the file with a text editor such as Notepad or use the options in Visual Studio to unload and edit the project.

image

The first thing is to add a ProjectTypeGuids node to the base PropertyGroup node. To get there you need to navigate to the PropertyGroup node (it is under the Project node) without any Condition attributes. On my machine that is on line 3

image

Next add the following line in the node:

<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Example: image

Next you need add a new project target into the Project node. You should already have one of these  around line 56

image

Right below that you need to add a new one (so you will have two), the line to add is:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets" />

Example: image

Now save the project file and re-open it in Visual Studio and the problems should be gone!

Troubleshooting

You may find that the designer is not working or you get errors when adding new activities still. In such a case it could be that you are missing the workflow foundation assemblies (System.Workflow.Activities; System.Workflow.ComponentModel; System.Workflow.Runtime):

image

Once you have those added everything should be working fine.