none
CCF 2008 - SetContextValue, InvalidOperationException thrown RRS feed

  • Question

  • Hi,

    I'm passing some information across CCF actions using Context values.

    At action execution, i'm registering for control event (RegisterActionForEvent), because it activity don't have like ActionData parameter, i'm using GetContextValue and SetContextValue activities to send information to registered action.

    Sometimes, it works fine, but sometimes it throw this exception when it intersect with NotifyContextChange on another app:


    WF/Automation 9b2d9060-5151-43b3-80e9-04d87d9911b8 exception: System.InvalidOperationException: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
       at Microsoft.Ccf.Csr.Context.GetContext()
       at Microsoft.Ccf.Csr.Context.get_ContextInformation()
       at Microsoft.Ccf.Csr.AutomationAdapter.<>c__DisplayClass7.<SetContextValue>b__6(Object )
       at System.Threading.SynchronizationContext.Send(SendOrPostCallback d, Object state)
       at Microsoft.Ccf.Csr.AutomationAdapter.SetContextValue(String key, String value)
       at Microsoft.Ccf.HostedApplicationToolkit.AutomationHosting.AutomationBridgeService.SetContextValue(String key, String value) in c:\Ccf\v3.0\CcfEverest\CcfEverestFull\Sources\Private\Microsoft.Ccf\Microsoft.Ccf\HostedApplicationToolkit\AutomationHosting\AutomationBridgeService.cs:line 69
       at Microsoft.Ccf.HostedApplicationToolkit.Activity.SetContext.ExecuteImpl(ActivityExecutionContext context, AutomationBridgeService service) in c:\Ccf\v3.0\CcfEverest\CcfEverestFull\Sources\Private\Microsoft.Ccf\Microsoft.Ccf\HostedApplicationToolkit\Activity\Activities\SetContext.cs:line 77
       at Microsoft.Ccf.HostedApplicationToolkit.Activity.CcfActivityBase.Execute(ActivityExecutionContext executionContext) in c:\Ccf\v3.0\CcfEverest\CcfEverestFull\Sources\Private\Microsoft.Ccf\Microsoft.Ccf\HostedApplicationToolkit\Activity\Activities\CcfActivityBase.cs:line 88
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
       at System.Workflow.Runtime.Scheduler.Run()

    Then, i have three questions:

    1. Do anybody knows another way to pass information to registered actions (RegisterActionForEvent)?
    2. If not, anybody knows how to avoid this exception?
    3. Can i create another key-value collection context like?

    Thanks in advance,

    Brian.

    Monday, May 4, 2009 10:21 PM

Answers

All replies

  • Hi Brian,

    there are two things you could try.

    1. run the Automations (CCF Actions) that cause the exception synchronously. You can do this by unselecting the "Asynchronously" check box in the CCF Action configuration dialog (http://msdn.microsoft.com/en-us/library/dd632299.aspx).
    2. use the GetActionData an SetActionData WF Activities (http://msdn.microsoft.com/en-us/library/dd632099.aspx).

    -Torsten


    CCF PM
    • Marked as answer by Brian_Garnica Wednesday, May 6, 2009 3:51 PM
    Tuesday, May 5, 2009 1:37 AM
  • I tend to use the RegisterActionforevent shape to trigger other automations/actions.

    As such it’s a separate automation / independent run.

    Is that what you are doing?  Or are you in the same Automation?

     

    Based on the exception, it looks like you are throwing it in a call to SetContext  via the hat automation shape,  is that correct?

    - MattB.

    Wednesday, May 6, 2009 3:31 PM
    Moderator
  • Hi Brian,

    there are two things you could try.

    1. run the Automations (CCF Actions) that cause the exception synchronously. You can do this by unselecting the "Asynchronously" check box in the CCF Action configuration dialog (http://msdn.microsoft.com/en-us/library/dd632299.aspx ).
    2. use the GetActionData an SetActionData WF Activities (http://msdn.microsoft.com/en-us/library/dd632099.aspx ).

    -Torsten


    CCF PM

    Hi Torsten,

    Thanks for your reply,

    1. I will try changing actions configuration (synchronously ).
    2. Using GetActionData and SetActionData, i can pass information across CCF Actions??

    Imagine this scenario:
    - I'm firing an scpecific automation on a WindowShown event (Automation1).
    - At this, i'm subscribing to firing another automation (Automation2) on windows controls events, as ButtonPressed for example, by RegisterActionForEvent.
    - RegisterActionForEvent don't have ActionData like property, for this, i'm using SetContext shape for pass information to registered action.
    - I suspect that context values are "overriding"... or "adding" at same time.
    - If at Automation1, i replace SetContext shape by SetActionData, and at Automation2, i replace GetContext shape by GetActionData, would it works??
    - I mean: Are this activities dependent on parent automation?

    Thanks.

    Regards.
    Wednesday, May 6, 2009 4:13 PM
  • Based on the exception, it looks like you are throwing it in a call to SetContext  via the hat automation shape,  is that correct?

    Sorry for my english.

    I don't know if I've understood correctly.

    I use SetContext on Automation1 (for pass information to Automation2), following, i use RegisterActionForEvent (on a while cycle) to register to control events.

    Sometimes, this information is overriden... obviously, but i don't know another way to pass information to registered action

    On this events, i get context information using GetContext.

    Thanks.
    Thursday, May 7, 2009 7:32 PM