Adding a VisualDesigner and Toolbox icon to a XAML Activity RRS feed

  • Question

  • I'm working on a project to provide a user task system which can be linked into our WF4.5 Workflows. Our Workflows will all be running as XAMLX services under AppFabric. So I have created a number of coded activities to provide the low level funcitonality to interact with our task services. These all work well and I have provided toolbox items and designers for each of these.

    For my next step, I want to create a few reusable XAML workflows that plumb together the various task activities. I started doing this as code activities, but started stuggling when I needed to build in the Receive activites and do correlation (needed to wait for a response from a waiting user task). So I switched to doing this in XAML activites which are far easier to build and maintain. This all works nicely, until I started to try to add the visual designers and icons so they match the coded leaf activities.

    In my coded activites I just added a couple of attibutes to the class:

    So, following the same principle, I added a code behind to my XAML activity and added these attributes to that. I rebuilt the project and my icons and designer were there, fantastic....So I created a test XAMLX service and dropped my XAML activity on it and ran the test, which worked.

    However, I then used a c# expression to set a parameter on one of the coded activities within my XAML file. When I then ran the test I get an exception of:

    Expression Activity type 'CSharpValue'1' requires compilation in order to run.

    There are several articles on this, but all are refering to self-hosting environments, I'm wanting to use the XAML services via Appfabric so I have no control over the hosting.

    Has anyone come across thsi problem, or found another way to add a visual designer / icon to a XAML activity ?

    Monday, January 28, 2013 3:28 PM


All replies

  • 1. As for the error  Expression Activity type 'CSharpValue'1' requires compilation in order to run.  Please have a look at  (WF4.5) Using CSharpValue<T> and CSharpReference<T> in .Net 4.5 Compiling expressions–and changes in Visual Studio generated XAML

    2. There are two ways to associate designers with activities:

    • Add Designer attribute to the activity (like you describe)
    • Use MetadataStore.  The metadata store is a Windows Workflow Designer feature that allows for the association of arbitrary metadata, in the form of CLR attributes, to types at runtime. This allows for a loose coupling between the run-time components and their design-time counterparts, as well as the ability to change the design-time components without affecting the runtime. See Associating a WF4 activity designer to a custom activity using MetadataStore for details.
    • Marked as answer by JonWilks Tuesday, January 29, 2013 12:32 PM
    Tuesday, January 29, 2013 8:33 AM
  • Thanks for the help. I've already tried most fo your suggestions but have hit snags for each and struggled to get past them.

    In terms of the 'CSharpValue' issue, I tried to add the ExpressionCompilation stage. I did this on the XAMLX file using the information on the following Link. This compiled and ran ok (can step through the code in the debugger). But still got the 'CSharpValue' error. I wondered if as my XAML activity is a child of the XAMLX service if I would have to add code to compile that as an additional step of whether this would be managed by the service compile, however as yet I havn't found a way to either check if this is happening or insert a compilation stage for the XAML Activity.

    In terms of the Designer, well option 1 is a non starter if I cannot solve the 'CSharpValue' error so based on your suggestion I thought I'd take a stab at the MetadataStore option. This looks pretty good and I can get the visual designer working, so thanks for the pointer here.  My only aesthetic problem now is how the get the toolbox icon attached (picky picky...).

    Closer and closer.....thanks for the help

    Tuesday, January 29, 2013 12:32 PM
  • Would be good if you post a simple code that allows to reproduce the problem. We plan to migrate our workflow solution to .NET 4.5. Therefore would be good to see possible problems.

    Currently we use WF 4 and also use XAML-based workflows and activities, but we our approach of executing child workflows are more generic. For "in-process" execution we are using WF4 How To Invoke a Child Workflow as XAML.

    In addition our system supports sub-processes (child workflows) as a service. Very similar to the approach described here Activities vs WF Services: In search of the ideal authoring experience.

    Tuesday, January 29, 2013 12:51 PM