WorkflowHostingEndpoint.OnGetInstanceId Method (Object[], OperationContext)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Override to return the instance ID for the workflow instance being created.

Namespace:   System.ServiceModel.Activities
Assembly:  System.ServiceModel.Activities (in System.ServiceModel.Activities.dll)

protected internal virtual Guid OnGetInstanceId(
	object[] inputs,
	OperationContext operationContext


Type: System.Object[]

The inputs to the service operation.

Type: System.ServiceModel.OperationContext

The operation context of the service operation.

Return Value

Type: System.Guid

The instance ID for the newly created workflow instance.

Return null to indicate that an instance ID should be automatically generated.

The following example shows how to implement the OnGetInstanceId method.

protected override Guid OnGetInstanceId(object[] inputs, OperationContext operationContext)
    //Create was called by client
    if (operationContext.IncomingMessageHeaders.Action.EndsWith("Create"))
        return Guid.Empty;
    //CreateWithInstanceId was called by client
    else if (operationContext.IncomingMessageHeaders.Action.EndsWith("CreateWithInstanceId"))
        return (Guid)inputs[1];
        throw new InvalidOperationException("Invalid Action: " + operationContext.IncomingMessageHeaders.Action);

.NET Framework
Available since 4.0
Return to top