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

I am trying to accomplish something that seems very simple. I have a Console Application Machine Machine Workflow with a workflow in it. I created a custom job for it. This activity will NEVER be used by ANYONE ABOVE. I just want to use this action for my workflow, but:

  • It does not appear in the toolbar.
  • I can't drag it from Solution Explorer to the workflow designer.

I absolutely do not want to create a separate Activity State Workflow Workflow library as it just clutters my solution. As I said, I will never use this activity in any other project, so I would like to limit myself to this ... but I just cannot figure out how to get it on the designer! I'm going crazy!?

Here is the action code:

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;
    }
}

      

Thank.


EDIT:

OK, so I found that if I change the project type from Console Application to Class Library, the custom activity appears in the toolbar. However, this is not acceptable. It must be a console / Windows application.

Does anyone know about this?

+2


source to share


3 answers


It looks like you found a bug in Visual Studio. I'm sure you could hack it to make it work, but have you thought what has to do with it and keep the bit of the workflow in the class library and reference them from a simple console application? Yes, it creates EXE and DLL, but the cost is trivial and actually separates your layers (UI and business logic) better and allows for better future use.



0


source


I'm leaving my machine so I can't test this idea, but you tried to go into the designer's code file and manually insert the minimal code, then go back to the designer to see if there is?



You didn't say if you have a designer creating XAML or C #, but even if it's XAML, you must be able to edit the XML to do so.

0


source


All you have to do is build a project. If it compiles successfully, it should appear in the toolbar. The designer only reads the actions from any last successful build.

0


source







All Articles