VB.net implementaion does not return Instnceid

I ran Asp.net implementaion of Hello World in VB.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim workflowRuntime As WorkflowRuntime = WorkflowWebRequestContext.Current.WorkflowRuntime

Dim scheduler As ManualWorkflowSchedulerService = workflowRuntime.GetService(Of ManualWorkflowSchedulerService)()

Dim workflowType As System.Type

AddHandler workflowRuntime.WorkflowCompleted, AddressOf WorkflowRuntime_WorkflowCompleted

' Load the workflow type

workflowType = GetType(WorkflowLibrary1.differentWorkflow)

' // dynamically load the workflow assembly

Dim WorkflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(workflowType)

WorkflowInstance.Start()

' // Now run the workflow. This is necessary when using the ManualWorkflowSchedulerService

scheduler.RunWorkflow(WorkflowInstance.InstanceId)

Dim myguid As System.Guid = WorkflowInstance.InstanceId ' // Has null in it

End Sub

Where as the Asp.net implementaion of CS produces the result:

private void StartSimpleWorkflow()

{

// Get a reference to the Workflow Runtime through the WorkflowWebHostingModule

// Http Module.

//

// NOTE: This requires the configuration section to be named "WorkflowRuntime".

WorkflowRuntime workflowRuntime = WorkflowWebRequestContext.Current.WorkflowRuntime;

// Now get a refernece to the ManualWorkflowSchedulerService

ManualWorkflowSchedulerService scheduler =

workflowRuntime.GetService<ManualWorkflowSchedulerService>();

// Attach to the WorkflowCompleted event

workflowRuntime.WorkflowCompleted +=

new EventHandler<WorkflowCompletedEventArgs>(WorkflowRuntime_WorkflowCompleted);

// Start the Workflow1

WorkflowInstance workflowInstance=workflowRuntime.CreateWorkflow(typeof(WorkflowLibrary1.differentWorkflow));

workflowInstance.Start();

// Now run the workflow. This is necessary when

// ...using the ManualWorkflowSchedulerService

scheduler.RunWorkflow(workflowInstance.InstanceId);

System.Guid myguid = workflowInstance.InstanceId; // This has the GUID that I need

}



Answer this question

VB.net implementaion does not return Instnceid

  • GethWho

    Wow - that doesn't work either - Guid.NewGuid doesn't seem to work from VB.NET. Crazy.

  • Jon Russell

    If you need a Guid - I'd recommend using the overloaded version of CreateWorkflow:

    Dim id as Guid = Guid.NewGuid()

    instance = workflowRuntime.CreateWorkflow(workflowType,null,id)



  • NateKing

    Oh - me again - it isn't a bug Tom - its the VB.NET IDE - always reports Guid instances as being Empty. If you do this in quickwatch or intermediate window -

    workflowInstance.InstanceId.ToString()

    it prints the property value.



  • El locolito

    This is a bug.

  • IMOFirey

    Thank you all for responding to the query.

    So the final verdict:

    It is the VB.NET IDE behavior and not a Bug in Workflow.

    Thanks all again for your time.


  • denszon

    Sorry - that should be Nothing - not "null" - doh!

  • VB.net implementaion does not return Instnceid