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?