Adding Items to the Toolbox in WF 4.0
I was working through a HOL not following directions (as usual) and I hit an error. The code block was:
ToolboxControl toolbox = new ToolboxControl();
ToolboxCategoryItemsCollection categories = new ToolboxCategoryItemsCollection("My Category");
ToolboxItemWrapper tool = new ToolboxItemWrapper("CustomActivities.Prompt", " CustomActivities", null, null);
ToolboxItemWrapper("System.Activities.Statements.Sequence", " System.Activities", null, "Sequence");
categories.Tools.Add(tool);
categories.Tools.Add(tool2);
toolbox.Categories.Add(categories);
When it ran I would get a run time error at the when toolbox.Categories.Add(categories) executed. The error informed me the System.Activities library was not found. That didn't make a whole lot of sense to me since I had the reference set and the library was most definitely in the framework. After a bit of messing around what I discovered is that at the point of executing Categories.Add() the framework was attempting to resolve the libraries that I had assigned to the ToolboxItemWrappers that I had created and added to the .Tools collection. Modifying the line for the creation of tool2 to be:
ToolboxItemWrapper tool2 = new ToolboxItemWrapper("System.Activities.Statements.Sequence", " System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", null, "Sequence");
Gave the framework the right information to find the proper library and load it.
Comments
- Anonymous
April 27, 2009
PingBack from http://asp-net-hosting.simplynetdev.com/adding-items-to-the-toolbox-in-wf-40/