Adding activities out of box to the VS toolbox

In the previous posts, we have already see as to how we can get the custom activities shown up in the toolbox. Either the activity is part of your solution or we use the Choose Toolbox Item dialog.

However, some of our customers want to deliver their custom activities out of box. Their user shouldn't be asked do a Choose Toolbox Item for every activity they want to use. Even one of our internal customer faced the same problem. Below is the step by step approach in how they went about solving the problem:

1. Lets start with out activity which we want to appear in VS out of box. Create the activity. For this sample, we will use a CodeActivity called “MyActivity”

2. Create a Visual Studio Integration Package “MyToolboxItem”

o Add the following two attributes to the package class


o Add the event handlers for “ToolboxInitialized” and “ToolboxUpgraded”. The event handler would use the SVsToolbox service to add the entries to the toolbox. The code looks as follows

void AddActivityToToolbox(object sender, EventArgs e)
IVsToolbox toolbox = (IVsToolbox)this.GetService(typeof(SVsToolbox));
if (toolbox != null)
OleDataObject dataObject = new OleDataObject();
AssemblyName assemblyName = typeof(MyActivity.MyCodeActivity).Assembly.GetName();
assemblyName.CodeBase = @"c:\public\ToolboxItemSample\MyActivity\bin\Debug\MyActivity.dll";
dataObject.SetData("AssemblyName", assemblyName);
dataObject.SetData("CF_WORKFLOW_4", "MapperActivity");
dataObject.SetData("WorkflowItemTypeNameFormat", typeof(MyCodeActivity).AssemblyQualifiedName);
TBXITEMINFO[] toolboxItemInfo = new TBXITEMINFO[1];
toolboxItemInfo[0].bstrText = ActivityName;
Bitmap bmp = new System.Drawing.Bitmap(16, 16);
toolboxItemInfo[0].hBmp = bmp.GetHbitmap();
toolbox.AddItem(dataObject, toolboxItemInfo, CategoryName);

3. Build the above package and create the registry keys to import by running

"c:\Program Files\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Tools\Bin\RegPkg.exe" /codebase /regfile:myActivity.reg /root:SOFTWARE\Microsoft\VisualStudio\10.0 C:\public\ToolboxItemSample\MyToolboxItem\bin\Debug\MyToolboxItem.dll

4. Close all running devenv instances and import the registry settings by running “myActivity.reg”

5. If you now run toolboxdecatur.exe /persistAll, you will see something as in the attached file(RegsitryEntries.txt).

And you are set. Create a new Workflow Project and you will see the new category and the activity in the Toolbox.

In VS 2010, WF toolbox follows the registry model for the out of box activities. Our activities have been registered as well in the registry. Hence, anyone who wants to have the out of box toolbox activity behavior, can do the same using the above. Essentially, we are creating the toolbox item the way VS toolbox understands it using a VS Integration package(Yes – You would need VS SDK). The next step is to extract that information as registry entries and then adding them to the registry hive.

Finally, in order to add the activity on the designer, ensure that either the activity is in the location mentioned above through the code base or by adding an explicit reference to MyActivity.dll or by putting it in GAC.

Hope this helps



Comments (4)

  1. WillSullivan says:

    Thanks for that.  Was wondering how to get around that limitation.  

  2. Ben Lambert says:

    Using this same technique, how can I set the tooltip for the toolbox item?  

    I'm writing a package that will add custom activities to the toolbox when a menu item is clicked.  I've created my VsPackage that adds the menu item, and in the menu callback I iterate through a subset of my custom activities and add toolbox items using your AddActivityToToolbox.  This works great, but I can't set the Tooltip so all it shows is the activity display name.

    Is there a way to set the tooltip?  Anything else I can pass into the DataObject, or set on the TBXITEMINFO?

  3. Hi Kushal, thanks for this post. Any idea how to configure the data so that you can add multiple assemblies to the project when the item is dragged from the toolbox?

    @Ben, see…/158f29e4-a134-4b72-b0a2-1f23415514cc for using a custom tooltip.

  4. cherry says:

    British reporters are known for doing almost anything to get a Mulberry Bags. But reports that a newspaper secretly listened to telephone messages of murdered schoolgirls and other private citizens have produced Mulberry Handbags and anger.

    On Friday, British police arrested Andy Coulson, former editor of Mulberry Bag Britain's best-selling newspaper, News of Mulberry Outlet the World. The investigation led him to Mulberry UK Sale resign in January as communications director to Prime Minister David Cameron.

    The arrest came in a widening investigation of Mulberry UK telephone hacking. Other accusations include paying police for mulberry shoulder bags information on stories. The Reuters news agency reported that Mr. Coulson was released on Mulberry Bag UK until a date in October.

    Prime Minister Cameron promised Men's Mulberry Bags Friday that a judge will lead a full public inquiry into Women's Mulberry Bags the case after police complete their investigation.

    DAVID CAMERON: "Murder victims, terrorist victims, families who have lost loved ones, sometimes defending our country, that these people could have had their phones hacked into, in order to generate stories for Mulberry Bags  Mulberry Handbags  Mulberry Bag   Mulberry Outlet  Mulberry UK  mulberry bayswater bag  Mulberry Alexa Bag, is simply disgusting."

Skip to main content