.NET Framework Developer Center > .NET Development Forums > Windows Workflow Foundation > Determining all of a Workflow’s WCF contracts at runtime
Ask a questionAsk a question
 

AnswerDetermining all of a Workflow’s WCF contracts at runtime

  • Saturday, October 17, 2009 7:11 AMErnie L Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    In WF 3.5 I’m creating a WCF Workflow hosting service. The goal is to be able to pass it any workflow type and have a WorkflowServiceHost created and configured to host that type.

    I’m not using any config files. All the WCF configuration is being done in code. The workflow type isn’t actually known until runtime. I’m loading the workflow assemblies at runtime through reflection and a simple form of dependency injection. Simplified code looks like this:

      public void HostWorkflow(Type workflow)

    {

    WorkflowServiceHost host = new WorkflowServiceHost(workflow);

     

    NetTcpContextBinding contextBinding = new NetTcpContextBinding (SecurityMode.None);

    Uri baseAddress = new Uri("baseaddress/" + workflow.FullName);

    host.AddServiceEndpoint(typeof(IInterface), contextBinding, baseAddress);

    }

     

    My question is: How do I determine what service contracts are used by a specific workflow’s WCF receive activities at runtime so that I can correctly configure the WorkflowServiceHost’s endpoints.  In other words, how do I determine the one or more interface types of IInterface  in the example above?

    When I get it wrong, the runtime throws an exception “System.InvalidOperationException: Type 'IInterfaces' is not found in the list of implemented contracts.” How do I get that list of implemented contracts?

Answers

  • Friday, October 23, 2009 10:30 AMAndrew_ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,Ernie

    Do you mean you want to create a workflow instance dynamically in the runtime, then publish the newly created workflow as a WCF service?Unless you have the interface(contract) in the server side already, I don't think you can do it in the runtime.

    Regards



    Microsoft Online Community Support

All Replies

  • Friday, October 23, 2009 10:30 AMAndrew_ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,Ernie

    Do you mean you want to create a workflow instance dynamically in the runtime, then publish the newly created workflow as a WCF service?Unless you have the interface(contract) in the server side already, I don't think you can do it in the runtime.

    Regards



    Microsoft Online Community Support