Windows Workflow Foundation 3


How to get WorkflowInstance from Workflow Runtime


 
When I get the Workflow Instance from Workflow Runtime I am getting the following exception. Can anyone please help.
WorkflowInstance wi = workflowRuntime.GetWorkflow(workflowInstanceId); This is the syntax used.
This I am doing in the second form where as my Runtime is created in the first form. I declared the Runtime as a static member and so I am able to get the reference in the next form.
Please help.
 
A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Workflow.ComponentModel.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>TitleStateApplication.vshost.exe</AppDomain><Exception><ExceptionType>System.IndexOutOfRangeException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Index was outside the bounds of the array.</Message><StackTrace> at System.Workflow.ComponentModel.Serialization.ActivitySurrogate.ActivitySerializedRef.System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(Object sender)
at System.Runtime.Serialization.DeserializationEventHandler.Invoke(Object sender)
at System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity, IFormatter formatter)
at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity)
at System.Workflow.Runtime.Hosting.WorkflowPersistenceService.RestoreFromDefaultSerializedForm(Byte[] activityBytes, Activity outerActivity)
at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.LoadWorkflowInstanceState(Guid id)
at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor)
at System.Workflow.Runtime.WorkflowRuntime.Load(Guid&amp; key, CreationContext context)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflowInstance(Guid instanceId)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
at TitleStateApplication.Payment._makePayment_Click(Object sender, EventArgs e) in D:\DOT-NET\Projects\Solution1MP\TitleStateApplication\TitleStateApplication\Payment.cs:line 39
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TitleStateApplication.Program.Main() in D:\DOT-NET\Projects\Solution1MP\TitleStateApplication\TitleStateApplication\Program.cs:line 18
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Workflow.ComponentModel.Serialization.ActivitySurrogate.ActivitySerializedRef.System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(Object sender)
at System.Runtime.Serialization.DeserializationEventHandler.Invoke(Object sender)
at System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity, IFormatter formatter)
at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity)
at System.Workflow.Runtime.Hosting.WorkflowPersistenceService.RestoreFromDefaultSerializedForm(Byte[] activityBytes, Activity outerActivity)
at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.LoadWorkflowInstanceState(Guid id)
at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor)
at System.Workflow.Runtime.WorkflowRuntime.Load(Guid&amp; key, CreationContext context)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflowInstance(Guid instanceId)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
at TitleStateApplication.Payment._makePayment_Click(Object sender, EventArgs e) in D:\DOT-NET\Projects\Solution1MP\TitleStateApplication\TitleStateApplication\Payment.cs:line 39
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TitleStateApplication.Program.Main() in D:\DOT-NET\Projects\Solution1MP\TitleStateApplication\TitleStateApplication\Program.cs:line 18
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>
Take a look at post http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=448452&SiteID=1&mode=1 for more info.

Related Links

Hands on Labs 2.2
WF Virgin
Error in the Hands on lab 09
Workflow Designer
How do you load XOML only State Workflow in WFPad for WWFBeta 2.2 (with namespace for codebehind assembly, and activities)?
invoke sub StateMachine workflow
Using WWF to model and support "Tech Trees" in RTS games
RuleConditionDialog and intellisense
Workflow Persistence & Event Arguments
PersistenceService - Transaction Timeout
SimpleExpenseReport
SQLTrackingQuery from Workflow
CreateWorkflow failing validation
xbox live mic help
download code samples of Microsoft press' windows workflow foundation step by step - Kenn Scribner
Advantage and disadvantage of ASP.NET WorkFl

Categories

MSDN
Visual Studio Team Fou...
Architecture
Windows Embedded Compact
WebsitePanel
Development
Office Live Development
Microsoft Atlas API: D...
Bing Ads API: Development
Exchange Server
Project
Archived Forums SN-SZ
Archived Forums T-U
Kinect for Windows SDKs
Archived Forums
Maps In Windows
Cortana
Visual Basic
Visual Studio LightSwi...
Testing with Visual St...
Test Tools in Visual S...
Developing Universal W...
Microsoft Message Queu...
Peer-to-Peer Networkin...
Windows Desktop Search...
Windows Desktop Web Se...
Excel for Developers
SharePoint 2010 - Setu...
Cloud Services (Web an...
Azure Management Portal
Azure BizTalk Services
Azure Search
Azure DocumentDB
StorSimple
Azure Logic Apps
Azure DevTest Labs
Azure Functions
Visual FoxPro General
Architecture General
BizTalk Server Adapter...
WCF Data Services
Internet Explorer Exte...
Internet Explorer Web ...
SyncFx - SyncToy-File ...
Windows Mobile Develop...
SQL Server Master Data...
Windows Embedded 8 Sta...
Standard 2009: Compone...
Standard 2009: Tools
SQL Server 2012 Master...
Windows Live  Spaces: ...
MSDN, TechNet and Expr...
WebsitePanel - Support
SQL Server Protocols
Microsoft Lync Server ...
Silverlight Installati...
Hosting and Streaming ...
Silverlight 4
Programming Silverligh...
Visual Studio & Silver...
MVVM / ViewModel Patte...
WCF RIA Services with ...
Expression Web and Sup...
Expression Media
Connected Services Fra...
Retired SharePoint Bus...
.NET Remoting and Runt...
ADO.NET Entity Framewo...
Azure Troubleshooting,...
Developer Documentatio...
Feedback for Visual Ba...
Game Technologies: XNA...
General Troubleshootin...
HealthVault Data Types
(Retired) Exchange Pre...
Innovate on Office
Installing and Registe...
ISV Community Days
LightSwitch in Visual ...
Microsoft Security Dev...
Microsoft Unified Comm...
Office Live Small Busi...
Pex and Moles PowerTool
Phoenix
Search Server: Frequen...
Silverlight (formerly ...
Silverlight (formerly ...
Silverlight (formerly ...
Security for Azure
SQL Server 2014 Data Q...
SQL Server 2014 Analys...
Team Foundation Server...
Visual Basic Language
Visual Studio 2008 IDE...
Visual Studio Database...
Visual Studio Guidance...
Visual Studio LightSwi...
Visual Studio Source C...
Visual Studio Online "...
Windows Error Reportin...
Windows Live Alerts De...
Windows Live Controls ...
Windows Workflow Found...
Building Windows Store...
Windows Phone Preview ...
.NET Native Preview
Windows IoT
Skype Web SDK

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile