WF -- how do I use a custom activity without creating it in a separate Workflow Activity Library?

Posted by Kevin Craft on Stack Overflow See other posts from Stack Overflow or by Kevin Craft
Published on 2009-09-04T03:05:08Z Indexed on 2010/06/16 4:52 UTC
Read the original article Hit count: 273

I am trying to accomplish something that seems like it should be very simple. I have a State Machine Workflow Console Application with a workflow in it. I have created a custom activity for it. This activity will NEVER be used ANYWHERE ELSE. I just want to use this activity on my workflow, but:

  1. It does not appear in the toolbox.
  2. I cannot drag it from the Solution Explorer onto the workflow designer.

I absolutely do not want to create a separate State Machine Workflow Activity Library, since that will just clutter my solution. Like I said, I will never use this activity in any other project, so I would like to keep it confined to this one...but I just can't figure out how to get it onto the designer! Am I going crazy!?

Here is the code for the activity:

public partial class GameSearchActivity: Activity
{
	public GameSearchActivity()
	{
		InitializeComponent();
	}

    public static DependencyProperty QueryProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Query", typeof(string), typeof(GameSearchActivity));
    [Description("Query")]
    [Category("Dependency Properties")]
    [Browsable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public string Query
    {
        get
        {
            return ((string)(base.GetValue(GameSearchActivity.QueryProperty)));
        }
        set
        {
            base.SetValue(GameSearchActivity.QueryProperty, value);
        }
    }

    public static DependencyProperty ResultsProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Results", typeof(string), typeof(GameSearchActivity));
    [Description("Results")]
    [Category("Dependency Properties")]
    [Browsable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public IEnumerable<Game_GamePlatform> Results
    {
        get
        {
            return ((IEnumerable<Game_GamePlatform>)(base.GetValue(GameSearchActivity.ResultsProperty)));
        }
        set
        {
            base.SetValue(GameSearchActivity.ResultsProperty, value);
        }
    }

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    {
        IDataService ds = executionContext.GetService<IDataService>();
        Results = ds.SearchGames(Query);

        return ActivityExecutionStatus.Closed;
    }
}

Thanks.


EDIT:

OK, so I've discovered that if I change the project type from Console Application to Class Library, the custom activity appears in the toolbox. However, this is not acceptable. It needs to be a Console/Windows Application.

Anyone know a way around this?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about workflow-foundation