Custom TypeDescriptors and WF Activities

Link. October 9, 2006. Comments [1]. Posted in: .NET | WinFX | Workflow

While playing today with Windows Workflow Foundation I ran into something others might run into, and thought I would put it out there.

I've been playing specifically with extending in various forms the design time support for a custom activity, and playing with dynamic/synthetized properties on them. Usually this is done through a custom ActivityDesigner that manipulates the properties collection in PreFilterProperties(), and sometimes via the IDynamicPropertyTypeProvider interface (which so far I've found rather superflous).

Unfortunately, in this particular case that didn't do the trick, so I decided to go one step further and see if I could hack this by attaching a ICustomTypeDescriptor implementation to a custom activity via a custom TypeDescriptionProvider.

This didn't go too well. Several problems I've run into so far include:

  • All activities from a workflow disappearing on the designer (even though they are still there)
  • Ocassionally crashing Visual Studio :-)
  • Weird compilation errors during validation, like this:

    error 348: Compilation failed. Specified method is not supported

One of the issues at least seems to be caused by the fact that the CompositeActivity base class already has a custom type descriptor attached to it that you can't get at directly (since it's internal). I'll probably play with this some more, though from what I've seen so far it doesn't seem like it would accomplish what i was trying for even if I could work around the other issues.



Wednesday, December 06, 2006 11:32:22 AM (SA Pacific Standard Time, UTC-05:00)
Hi Tomas,
I've been working on the exact same thing for a few days now. I'm REALLY interested in doing this. I've taken the same approach and I'm almost done. Unfortunately, I've come across a show stopper that you might be able to figure out. I've got a custom activity called DataLinkActivity that contains a List<DataUrl> list. Other activities want to bind their own properties to items in the List<DataUrl>. Things work great at design time because I've written my own custom bind dialog. And I can create a workflow runtime instance because I've set the ValidateOnCreate parameter to false (WorkflowRuntimeSection setting).

But at runtime, when an activity tries to retrieve the dynamic DataUrl it's property is bound to the return value is false. Unfortunately, it's because the WF runtime uses standard reflection and to resolve the MemberInfo that the ActivityBind.Path refers to. ActivityBind.GetRuntimeValue calls ActivityBind.InternalGetRuntimeValue that calls ActivityBind.GetMemberInfo that calls MemberBind.GetMemberInfo that calls PathWalker.TryWalkPropertyPath (courtesy of Lutz Roeders reflector). And the TryWalkPropertyPath fails because the function can't resolve where the class member is that the dynamic property refers to. So the only way that you can actually bind to a property and have it return a value at runtime is if it corresponds to a member defined in some c# file - which really sucks!!! I could bind to an actual property that is the List<DataUrl> rather than an individual item in the list but then I don't know how to actually resolve which item in the list is wanted.

If you find a way to be able to bind to dynamically bind to properties that don't exist in a custom activities class definition, please let me know.
Comments are closed.

Syndicate

About

Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...

tomasrestrepo @ twitter My Flickr photostream My saved links on delicious My Technorati Profile

email: tomas@winterdom.com
msn: tomasr@passport.com

View my profile on LinkedIn

MVP logo

Ads


Links

Categories

Statistics

Total Posts: 1032
This Year: 102
This Month: 1
This Week: 1
Comments: 801

Blogroll

Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 2.1.8139.823

Sign In