workflow-foundation-4workflow-activity

WorkflowInspectionServices.GetActivities from "SubWorkflows"


I am getting an error running this code.

IEnumerable<Activity> activityList = WorkflowInspectionServices.GetActivities(activityCurrent);


if (activityList.Count() <= 0)

I have a number of workflow that I want to go through it's activities. I have no problem meanwhile the activities that I use in the workflows are code activities or native activities. The problem comes when I use another workflow in the workflow (I hope I am making sense with that)

The error is in the activityList.Count() which is Cannot create unknown type '{clr-namespace:....PhysicalInbound}Destination'.

Actually it works if I put the content of the "subworkflow" in the "Parent" workflow. My guess it is that have to do with the imports but I have not been able to figure it out so far : S

StackTrace:

   at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType)
   at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
   at System.Activities.XamlIntegration.FuncDeferringLoader.FuncFactory`1.Evaluate()
   at System.Activities.DynamicActivity.OnInternalCacheMetadata(Boolean createEmptyBindings)
   at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList`1& validationErrors)
   at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack`1& activitiesRemaining, ActivityCallStack parentChain, IList`1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
   at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
   at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
   at System.Activities.WorkflowInspectionServices.<GetActivities>d__0.MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)

Thanks for your time,

Joan.


Solution

  • I had the same problem. In my case it was because I put both Parent workflow and "subworkflows" in the same assembly.

    If it is your case, try putting them in another assembly as you do with activities.