.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to Add custom WF4 Activities to ToolBox using Code?

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :Windows Application
Hi I have a number of custom activities in my dll. My requirement is to add the custom activities to ToolBox using Code/installer. I written the following code System.Reflection.Assembly asm; asm = Assembly.LoadFrom(Path.Combine(assemblyPath, @"MyProject.dll")); var types = from t in asm.GetExportedTypes() where typeof(Activity).IsAssignableFrom(t) select t.FullName; if (types != null && types.Count() > 0) { string activityName; foreach (var item in types) { activityName = item.Substring(item.LastIndexOf(".") + 1); myTab.ToolBoxItems.Add(activityName, item); } } Above code is adding the activities to the Toolbox as HTML Controls. How can I add the same as WF4 Activities in Toolbox ? Thanks AmbilyIT Analyst

View Complete Post

More Related Resource Links

Creating Variables in "Parent" from Custom Activities in Code


Using Workflow 4, I've created a series of custom activities (e.g. Create Email, Upload Email To Document Management System etc.) that need to pass data between each other during execution within a "parent" workflow.. I've read that the recommended method to do this is by using variables declared at the correct scope.  This is easy to do in the designer, so in a standard flow diagram or sequence I create my variables manually, then drop in my custom activities as "children" and assign variables to their InArguments/OutArguments as appropriate.

Unfortunately, this is VERY manual and I'd like to do it in code if possible.   I know that I can create an OutArgument to pass the value back to the parent workflow.. but I need to dynamically create the workflow variable to store that value in as well.. I've read in other posts about people wanting to do similar things..

e.g. http://social.msdn.microsoft.com/Forums/en/wfprerelease/thread/4958777a-77c3-448b-aac5-6933eaf726f5

..some of them have tried using the NativeActivityContext.Property (doesn't work directly between two "siblings", they have to be put in a custom container that sets the needed values on its own context p

How do I Access Variables Between Custom Activities From Code?


Basically, I have custom activity and I have a variable in it that I would like to access in another custom actvity. It it possible to do this without writting the acutal workflow from code and still use the designer? The best way to describe it would be that I want to declare a global variable from within an activity that would be available to any other activity.

This is an example of what I am trying to:

public class activity1 : NativeActivity

    protected override void Execute(NativeActivityContext context)
      string text = "Sent between activities!";

And here is the activity in which I would like to get the contents of the property:

 public class activity2 : NativeActivity
    protected override void Execute(NativeActivityContext context)
      string text = "";
      text = Convert.ToString(context.Properties.Find("globalText"));

Stepping through the code shows that the "context" object has zero properties once I enter the second activity. According to different sources this should be working because the context object should still contain my property correct?

Toolbox: Database and OR/M Tools, Oren Eini and Custom Visual Studio Tabs


This month we look at tools for enhancing the LINQ to SQL and Entity Framework designers, Oren Eini's .NET development blog, Visual Studio tab customization, and more.

Scott Mitchell

MSDN Magazine December 2009

Toolbox: Data Snapshots, Subversion, Source Code Organization and More


If you want to save, organize, and annotate snapshots of your database data, find an easy way to install and configure Subversion, and automate the organization of your source code, then you'll want to read more about these latest tools.

Scott Mitchell

MSDN Magazine August 2009

Toolbox: Microsoft Chart Controls, Visual Studio Automatic Code Snippets, And More


In this installment we look at the Microsoft Chart Controls; Snippet Designer, a free, add-in for Visual Studio 2008 for creating and editing Code Snippets; refactoring SQL applications; and this month's favorite blog.

Scott Mitchell

MSDN Magazine April 2009

Wicked Code: Craft Custom Controls for Silverlight 2


If you're unfamiliar with Windows Presentation Foundation (WPF), building that first Silverlight custom control can be a daunting experience. This article walks through the process.

Jeff Prosise

MSDN Magazine August 2008

Toolbox: Database Audit Logs, Joel on Software, Code Handouts, and More


This month the Toolbox column takes a look at database logging, Joel Spolsky's blog, printing code projects, and ASP.NET reading.

Scott Mitchell

MSDN Magazine May 2008

Toolbox: SQL Code Completion, Subversion Tools, Agile Development, and more


This month: help writing SQL code, modeling your database with SubSonic, and a review of Visual Studio Team System: Better Software Development for Agile Teams.

James Avery

MSDN Magazine Launch 2008

Toolbox: Live Chat, Code Conversion, Multiple Monitors, and More


This month, more of the tools you need to get your job done.

Scott Mitchell

MSDN Magazine December 2007

Toolbox: Find Bottlenecks, Code Similarities, and More


This month, find performance and memory bottlenecks, essential security reading, and more.

Scott Mitchell

MSDN Magazine July 2007

Windows Workflow: Build Custom Activities To Extend The Reach Of Your Workflows


This article covers the core components required for building custom activities in Windows Workflow Foundation.

Matt Milner

MSDN Magazine December 2006

Toolbox: Protecting Code, Persisting Data, and More


This month obfuscating your code, persisting your data, and a good read on SQL Server 2005.

Scott Mitchell

MSDN Magazine October 2006

Toolbox: Code Generation, A Charting Component, and More


Developers have a number of tools at their disposal, but which of these components do you really need to complete your project? Each month we'll analyze the latest software and books to see if they merit inclusion in your toolbox.

Scott Mitchell

MSDN Magazine January 2006

Custom Cultures: Extend Your Code's Global Reach With New Features In The .NET Framework 2.0


The upcoming Microsoft .NET Framework 2.0 adds a number of globalization features that address the important issues of extensibility, standards support, and migration. Here authors Michael Kaplan and Cathy Wissink explain what these features mean to your globalization effort.

Michael Kaplan and Cathy Wissink

MSDN Magazine October 2005

Custom tool error: Failed to generate code for the service reference 'CompanyService'. Please che


A little background because I feel I have an out of the ordinary architecture in place and don't know if this is contributing to the problem. 

We have an existing ASP.net application that is undergoing expansion.  The new functionality is all written in Silverlight 4.  As part of that expansion I gutted all the old Linq to SQL and put Entity Framework 4 into place.  To do this I created a standard .net Class Library and added my edmx files there.  Naturally, the business entities created by this cannot be used in Silverlight.  So I created a Silverlight Class Library and added all the business entities to that Silverlight Class Library as linked files.  I changed the name space to be the same.

So I have the following assembly / namespaces

Company.Project.Dal.csproj / Company.Project.Entities (.net 4 class library)

Company.Project.Entities.csproj / Company.Project.Entities (SL4 class library)

With this architecture I was able to share my business entities with my SL enabled web services, my asp.net projects, my silverlight projects.  Really it's a beautiful thing.

Once this was done I added "message" classes to Company.Project.Dal and again shared them with the other entites using linked files.  These messages are things like MyObjectRequest; they are class

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend