views:

318

answers:

4

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?

A: 

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?

Kevin Craft
Sorry, I am a stackoverflow newb. Didn't realize I could edit my original post.
Kevin Craft
A: 

It looks like you've uncovered a bug in Visual Studio. I'm sure you could hack it to make it work, but, have you considered going with it and keeping the workflow bits in a class library and referencing them from a simple console application? Yes, this creates an EXE and a DLL, but the cost of doing so is trivial and actually separates your layers better (UI versus business logic) and enables better reuse in the future.

Jerry Bullard
A: 

I'm away from my machine so I can't check this idea but have you tried going into the designer's code file and manually inserting the minimal code and then going back into the designer to see if it's there?

You haven't said whether you've got the designer creating XAML or C# but even if it's XAML, you should be able to edit the XML to do that.

serialhobbyist
A: 

All you have to do is build the project. If it compiles successfully, it should show up in the toolbox. The designer only reads the activities from whatever the last successful build was.

Chris Stavropoulos