none
ActivityXamlServices.Load only supports Activity-based types.

    Question

  • Hi,

    When I try to load dynamically a xamlx file (workflow service) using the following line:

    Code: var workflow = ActivityXamlServices.Load(_fileName);

    It gives me this error:

    ActivityXamlServices.Load only supports Activity-based types.  Invalid type (System.ServiceModel.Activities.WorkflowService) was provided.
    Parameter name: reader

    I would like to make a simple activity that loads the activity(including workflow services activities like receive) at some place on the parent workflow.

    Thanks.

    Thursday, May 06, 2010 11:59 AM

Answers

  • do you mean you want to convert your xamlx file to workflow with some arguments property in your xaml file?

    if so, I think you can use dynamicactivity.

    I just added the first argument for you.

    you can also add other argument.

    object serviceImplementation = XamlServices.Load("d:\\temp.xamlx");
                WorkflowService service = serviceImplementation as WorkflowService;
                Activity activity = service.Body;
                DynamicActivity dyanamicActivity = new DynamicActivity();
                dyanamicActivity.Implementation = () => activity;
                DynamicActivityProperty prop = new DynamicActivityProperty
                {
                    Name= "Inputs",
                    Type = typeof(InArgument<IDictionary<string, object>>)
                };
                dyanamicActivity.Properties.Add(prop);

    • Marked as answer by Petrutiu Wednesday, May 12, 2010 7:51 AM
    Wednesday, May 12, 2010 4:40 AM

All replies

  • can you paste me your xamlx file content?
    Thursday, May 06, 2010 5:57 PM
  • object serviceImplementation = XamlServices.Load("temp.xamlx");

                using (WorkflowServiceHost host = new WorkflowServiceHost(serviceImplementation))
                {
                    host.Open();

                    // Create a client that sends a message to create an instance of the workflow.
                    ICountingWorkflow client = ChannelFactory<ICountingWorkflow>.CreateChannel(new BasicHttpBinding(), new EndpointAddress(ServiceEndpointAddress));
                    client.Start();

                    Console.WriteLine("(Press [Enter] at any time to terminate host)");
                    Console.ReadLine();

                    host.Close();
                }

     

    you can get the activity property from workflowserviceHost

    • Proposed as answer by Andrew_ZhuModerator Tuesday, May 11, 2010 1:40 AM
    • Unproposed as answer by Petrutiu Wednesday, May 12, 2010 4:31 AM
    Thursday, May 06, 2010 9:15 PM
  • Sorry for responding so late,(waiting for the alert)...

    Thanks for replying me so fast. This is nice, but I wanted to make some kind of activity that would be able to load any kind of activity. Because I know the inputs and the string that defines the workflow(xaml of xamlx file).

    So is there a way to make that kind of activity?

    Thanks.

    Tuesday, May 11, 2010 12:17 PM
  • what do you mean some kind of activity that would be able to load any kind of activity?

    could you show me some sample?

    Tuesday, May 11, 2010 5:41 PM
  • Ok. I want a workflow to be dynamically. And I would like to have an activity in this workflow, with this arguments for example:

      <x:Members>
        <x:Property Name="Inputs" Type="InArgument(scg:IDictionary(x:String, x:Object))" />
        <x:Property Name="Outputs" Type="OutArgument(scg:IDictionary(x:String, x:Object))" />
        <x:Property Name="XamlToLoad" Type="InArgument(x:String)" />
        <x:Property Name="NecessaryAssemblies" Type="InArgument(s:String[])" />
      </x:Members>

    Where Inputs would be the inputs needed for the Xaml, in Outputs I would store the outputs from this activity, XamlToLoad - the activity or workflow that I would like to load, NecessaryAssemblies would be the assemblies needed if the activity contains other activities from other assemblies that are not loaded already.

    I hope I was clear enough, if not, please take some of your time and ask me again what is not clear.I didn't show you the activity because Its not done yet.

    Wednesday, May 12, 2010 4:17 AM
  • do you mean you want to convert your xamlx file to workflow with some arguments property in your xaml file?

    if so, I think you can use dynamicactivity.

    I just added the first argument for you.

    you can also add other argument.

    object serviceImplementation = XamlServices.Load("d:\\temp.xamlx");
                WorkflowService service = serviceImplementation as WorkflowService;
                Activity activity = service.Body;
                DynamicActivity dyanamicActivity = new DynamicActivity();
                dyanamicActivity.Implementation = () => activity;
                DynamicActivityProperty prop = new DynamicActivityProperty
                {
                    Name= "Inputs",
                    Type = typeof(InArgument<IDictionary<string, object>>)
                };
                dyanamicActivity.Properties.Add(prop);

    • Marked as answer by Petrutiu Wednesday, May 12, 2010 7:51 AM
    Wednesday, May 12, 2010 4:40 AM
  • Thanks, now I am able to load the service. I will need now to check how could I call this service, and how could I make something similar for CodeActivity. The problem was that I was using ActivityXamlServices.Load to try load the service.
    Wednesday, May 12, 2010 7:51 AM