index > Windows Workflow Foundation > While loop only executes once

While loop only executes once

Hi

I want to use the While activity in a workflow I'm developing, however I have the following problem.

The the first time the while loop condition is evaluated it returns true so the contained activity should be executed (I have a code child activity that just writes to the console). However the code activity is not executed. The workflow is persisted and then nothing else happens.

I've been looking at the WhileAndParallel sample program to see if I'm missing anything. This runs fine as supplied. However if I move the workflow into my host and execute it there, the same thing happens - the loop condition evaluates to true and then the child activity is not executed.

Is there something obvious that I could be doing in my host to make this happen? I am using the SQLPersistenceService that comes with WF - I have also tried disabling the persistence service and it makes no difference.

Any ideas?

Cheers

Clare

PS I am using WinFx Runtime Components 3.0 Beta 2. OK I know this is a little old...

cgn
Try to print the condition expression to console in each loop, so you can know if it is because of the condition's status.
Vilsad

Hi

I checked this already and it does not explain why the sample works in one host and not the other.

Clare

cgn

I don't understand : how can the workflow be persisted if you disable the persistence service ?

 




Serge Luca; Guidance Belgium; blog: www.redwood.be
Serge Luca

Hello,

If I have the persistence service 'on' the the workflow is persisted after the while loop condition is evaluated.

If persistence service is 'off' then as you might expect the persistence does not occur ;)

I understand that the workflow is persisted on each iteration of the while loop (to allow roll back to occur if an error occurs), so I tried disabling the persistence service to see if it had any affect. I was looking for differences between my host and the one in the WhileAndParallel sample - the latter does not use a persistence service. Long shot I guess but I really am stuck here.

Clare

cgn

do you mean unloadonidle=true ?

and if you don't add the WorkflowPersistenceService to the runtime, does that work as expected ?




Serge Luca; Guidance Belgium; blog: www.redwood.be
Serge Luca

Clare,

I've patched the persistence sample sdk.

I've :

1?removed all the activities

2?added a while + a codeactivity

3?add int  _i; as workflow data member

4?in the while,  condition is _i < 10

5?displayed and incremented _i in the code activity

 

run : that works, but I use RC4....( as Tom would say , you should upgrade to a new build ).

 

 




Serge Luca; Guidance Belgium; blog: www.redwood.be
Serge Luca

Hi

After further investigation (and an upgrade as recommended but unfortunately this didnt fix it) I've discovered the following:

The While Condition is evaluated, an exception is thrown, then the workflow is terminated.

The message from the exeception is 'Error binding to target method'.

I've searched for this error message and find a few posts such as this one

http://www.dotnet247.com/247reference/msgs/30/153214.aspx

which seem to suggest recreating my visual studio project. Tried this - still doesnt work! I've cut back my visual studio solution to the minimum projects.

To reiterate, it is only workflows with a while loop where I encounter this problem. I have been sucessfully using this host for some time with no problems.

It's starting to sound like a visual studio problem more than a workflow foundation issue.

Does anyone have any experience with this?

Thanks a lot, Clare

cgn

Some more information......

I host the workflow runtime in a windows service and expose a 'submit' method via remoting.

In the submit method I reflect into the DLL containing the workflow to create the workflow type and then submit it to the workflow runtime.

I changed my host to create the workflow type statically in code and the workflow executes fine.

This sounds like a bug to me! Any comments?

Clare

cgn
Could you post some code that demonstrates the problem?


Scott [http://www.OdeToCode.com/blogs/scott]
Scott Allen
Can you post the stack trace forthe exception you are getting?


MS Workflow SDE/T - This posting is provided "AS IS" with no warranties, and confers no rights.
Tom Lake

Hi Tom

Here is the stack trace....

at System.Delegate.InternalCreateDelegate(Type type, Object firstArgument, MethodInfo method)

at System.DelegateSerializationHolder.GetDelegate(DelegateEntry de, Int32 index)

and the error message

"Error binding to target method."

Clare

cgn

Clare

Alex Mujar

Clare

Alex Mujar

Hi Alex

Yes that worked thanks a lot!

However I am a little confused as to why this should be the case. If I am reflecting into a dll to create an instance of the workflow class, why would the assembly be needed in the path after sucessful creation of an instance of the class?

Could someone enlighten me?

Cheers, Clare

cgn
reply 15

You can use google to search for other answers

 

More Articles

• How to go 'backwards' in a sequential workflow?
• human workflow
• Error compiling a Visual Studio solution using WWF
• How to Convert a User Control(dll) written in c# to ActiveX Contr...
• CallExternalMethod and CorrelationToken
• XOML Version (beta 1)
• ASP.NET hosting (WebService) of Windows Workflow Foundation
• Beta 2.2
• Adding TransactionScope to host application
• Developing on Windows XP SP2
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Notifying the Runtime Host Of A Workflow
• ParameterBinding loses Value in EventSin
• How to get child workflow instanceId aft
• Why do states require an event / delay?
• OSWorkflow vs WWF
• Dynamically changing rules definitions i
• "Workflow Patterns" evaluation
• Base Class and Inheritance
• WWF Beta 2 and RTM Schedule / Availability
• Workflow at presentation layer
• I can't find the workflow items in VS2005
• Workflow engine
• How to pass a GUID to a WebServiceInput
• WF and Smart Clients
• Adding services to the workflow runtime

Hot Articles

• Sequence vs. CompositeActivity Guidance
• SqlPersistanceService - Changing workflo
• xoml or xaml?
• Application architecture
• Raising events to State Machine workflow
• Problem serializing base classes on acti
• Want the webforms alternative for the wi
• Unable to use the ifElse Activity in an
• How to implement a PersistActivity or re
• Hiding workflow tabs (Exceptions, events
• Workflow state not persisting on Suspend
• Pass Guid as String in XmlHTTP
• CancellationHandlerActivity
• State machine workflow design questions
• Workflow Hosting:WCF NT-Service or WEBSe

Recommend Articles

• Asp.Net, state machine workflow, delay a
• State Machnine workflows and Correlation
• RaiseDataChanged and DuplicateInstanceId
• How do i implement this workflow ?
• ASP.NET hosting (WebService) of Windows
• Trouble with a while condition in a win
• Deserialization Error occured while load
• Turn "public" StateActivityDes
• XAML activation of HandleExternalEventAc
• Problems with the rules expressions bind
• SqlTrackingService - Events not tracked
• Custom Composite Activities and Correlat
• Windows Workflow Foundation and Active D
• Examples of workflows using Office 2007?
• Correlation with nested custom activities