SharePoint Dragons

Nikander & Margriet on SharePoint

Enabling the workflow DSL for a custom acitivity

Here’s a small trick for enabling the workflow DSL for a custom activity:

  1. First, create a new empty SharePoint project.
  2. Add a  reference to the System.Workflow.Activities assembly. It’s located in the GAC, and therefore it may be a bit of a hassle to reference it. For cases like these, we like to use Muse.VSExtensions ( http://visualstudiogallery.msdn.microsoft.com/36a6eb45-a7b1-47c3-9e85-09f0aef6e879 ) from the Visual Studio gallery. It adds a new menu option called Add GAC Reference that allows you to search for and reference assemblies in the GAC directly. If that’s not enough, it also adds a menu option that removes unused references. It’s a great tool, that works like a charm.
  3. Also add a reference to System.Workflow.ComponentModel.dll, also located in the GAC.
  4. Add a new class: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.Activities;

namespace SharePointProject1
{
    public partial class Class1 : SequenceActivity
    {
        public Class1()
        {
            InitializeComponent();
        }
    }
}

Finally, add another class called class1.designer.cs:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharePointProject1
{
    public partial class Class1
    {
        private void InitializeComponent()
        { }
    }
}

Now, when you click class1, you’ll find that now you can drag n drop activities. See http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/23f11f0f-d50d-4f99-a409-90f582b19442 for more info.

Advertisements

One response to “Enabling the workflow DSL for a custom acitivity

  1. Pingback: Enabling the workflow DSL for a custom acitivity - The Microsoft SharePoint Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: