Windows Workflow Foundation 3


Problem in WorkflowRuntime.WorkflowCompleted event


Problem in WorkflowRuntime.WorkflowCompleted event
My situation is :     I have a state machine workflow. In the workflow, I need call external method, and the parameter of the external method include the workflow's InstanceID. For example, in local service interface, there is a method like "void methodA(Guid instanceID, int ch)" . In order to trans the workflow instanceID the external method, I declare a property in my state machine workflow:        public Guid InstanceID        {            get            {                if (!DesignMode)                    return WorkflowInstanceId;                else                    return Guid.Empty;            }        }
because WorkflowInstanceId property of the workflow is runtime dependency, so I have to declare such a proerty. The Property does works . I give the intstanceID to the external method correctly.
But the problem comes!!!!! When I declare such a property in my workflow, I find that the WorkflowRuntime.WorkflowCompleted event doesn't fire when the workflow is completed! If I commet the property , WorkflowRuntime.WorkflowCompleted eventfire correctly.
  I don't know why this happened. But I do need to trans workflow's instanceID to the external method , how could I do?
I'm not sure what is happening there, but when you call an external method using the CallExternalMethodActivity, then this code executes in the context of the calling Workflow, and you can use WorkflowEnvironment.WorkflowInstanceId to get the InstanceID of the calling Workflow, so there should not be a need to explicitly pass in the InstanceId of the calling Workflow. So you could change your signature to methodA(int ch) and in methodA you could get the InstanceId using WorkflowEnvironment.InstanceId.
Can you give this a try and see if this works for you?
Thanks,
Steve Danielson [Microsoft]This posting is provided "AS IS" with no warranties, and confers no rights.Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
I'm not sure what is happening there, but when you call an external method using the CallExternalMethodActivity, then this code executes in the context of the calling Workflow, and you can use WorkflowEnvironment.WorkflowInstanceId to get the InstanceID of the calling Workflow, so there should not be a need to explicitly pass in the InstanceId of the calling Workflow. So you could change your signature to methodA(int ch) and in methodA you could get the InstanceId using WorkflowEnvironment.InstanceId.
Can you give this a try and see if this works for you?
Thanks,
Steve Danielson [Microsoft]This posting is provided "AS IS" with no warranties, and confers no rights.Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
Thanks , That's works.
    And I found why the workflow does not fire workflow completed event. it fires the event "ServicesExceptionNotHandled". I Step into my codes, and find that the exception just happened in my declare "InstanceID" property ' s "get" method . I don't know why. Does someone know it ?

Related Links

HandleExternalEvent: event filter / correlation
SqlTrackingService & User Events
How to change the sendemail activity property at run time?
Question on Queue Management
Load rules in the Designer Rehosting demo
IExtendedUIService must be installed
Does WF support transactions?
After wf receives external event, the host never sees any more tracking events
How to implement Unit test in a Sequential workflow
data exchange between workflow activities
While() activity a cpu hog
Share large data between workflow and application
General questions about WWF
InvokeWebService vs InvokeWorkflow
Database monitor activity???
Print WWF documentation

Categories

MSDN
Using Forums
Microsoft Office for D...
Apps for Office and Sh...
DevLabs
Microsoft ISV Communit...
Dynamics
Microsoft Research
Microsoft Azure
Archived Forums #
Archived Forums SN-SZ
Archived Forums T-U
Archived Forums Visual...
Cortana
Announcements for all ...
Submitting and Publish...
Windows App Studio Beta
User Interface develop...
SharePoint 2013 - Gene...
Developing Apps for Sh...
SharePoint 2013 - Search
SharePoint 2010 - Gene...
SharePoint 2010 - Deve...
SharePoint 2010 - Setu...
SharePoint Legacy Vers...
SharePoint Legacy Vers...
Azure Multi-Factor Aut...
Azure Scheduler
Azure Scripting and Co...
Azure Functions
Azure Data Lake Analyt...
Windows Presentation F...
Windows Communication ...
Windows Workflow Found...
Commerce Server 2007
Microsoft Solver Found...
Microsoft Translator H...
SyncFx - General [Read...
SQL Server Integration...
SQL Server Security
SQL Server Notificatio...
SQL Server Search
SQL Server Distributed...
SQL Server 2012 Report...
Windows Forms Designer
Windows Forms Sample A...
Windows Live Messenger...
WebsitePanel - Support
WebsitePanel - Enterpr...
Windows Protocols
Bing Ads API: Development
Microsoft Lync Persist...
Microsoft Lync Server ...
Silverlight Controls a...
Expression Blend + Ske...
Expression Design
Expression Studio
Windows Performance To...
Retired InfoPath Forms...
Retired SharePoint Soc...
Project Standard and P...
.NET Framework 4 setup...
.NET Framework 4: Wind...
ADO.NET Entity Framewo...
Archived: Software Tes...
Axum Incubation Project
App Producer (archived)
Charts & Reports in th...
Commerce Server 2002 a...
Deep Zoom Composer
Dynamic Languages on .NET
Getting Started With V...
Face Tracking – Kinect...
Installing and Registe...
Office Live Small Busi...
Performance Counters f...
Project Codename:  Jasper
Search Server: Federation
Search Server: Known B...
Small Business Applica...
SyncFx - Microsoft Syn...
SyncFx - Technical Dis...
SQL Azure Labs Support
Team Foundation Server...
Tailoring your Windows...
Visual Studio 2008 (Pr...
Visual Studio Lab Mana...
Visual Studio Source C...
Visual Studio Team Sys...
Visual Studio Tools fo...
Web Sandbox - General
Windows Desktop Vista ...
Windows MultiPoint Mou...
Windows Presentation F...
Windows SideShow Devel...
Windows Phone Preview SDK
Microsoft Graph

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile