VB.net implementaion does not return Instnceid

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

ProtectedSub Button1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Button1.Click

Dim workflowRuntimeAs WorkflowRuntime = WorkflowWebRequestContext.Current.WorkflowRuntime

Dim schedulerAs ManualWorkflowSchedulerService = workflowRuntime.GetService(Of ManualWorkflowSchedulerService)()

Dim workflowTypeAs System.Type

AddHandler workflowRuntime.WorkflowCompleted,AddressOf WorkflowRuntime_WorkflowCompleted

' Load the workflow type

workflowType =GetType(WorkflowLibrary1.differentWorkflow)

' // dynamically load the workflow assembly

Dim WorkflowInstanceAs WorkflowInstance = workflowRuntime.CreateWorkflow(workflowType)

WorkflowInstance.Start()

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

scheduler.RunWorkflow(WorkflowInstance.InstanceId)

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

EndSub

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

privatevoid 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 +=

newEventHandler<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

}

[13074 byte] By [sam-pan] at [2007-12-19]
# 1
This is a bug.
TomLake at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

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)

JonFlanders at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Sorry - that should be Nothing - not "null" - doh!
JonFlanders at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
Wow - that doesn't work either - Guid.NewGuid doesn't seem to work from VB.NET. Crazy.
JonFlanders at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5

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.

JonFlanders at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

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.

sam-pan at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified