I have added the service to the WorkflowRuntime and used the UnLoad() of Workflow Instance. But still I could not see the data getting persisted.
Can anyone please help
I have added the service to the WorkflowRuntime and used the UnLoad() of Workflow Instance. But still I could not see the data getting persisted.
Can anyone please help
WWF-SqlWorkflowPersistenceService
pratcp
The sample program runs well in my machine. But even there I am not able to see any data in the tables.
Even after specifying the flag to "true", it still does not work.
Is there any thing else I need to do
I have iuntroduced a delay object in the workflow now and also I just copy pasted the code in the sample(given below), expecting it to run by itself. Is there anything else I should do I am not invoking the below given method anywhere.
static void UnloadInstance(object workflowInstance){
((
WorkflowInstance)workflowInstance).TryUnload();}
}
Please help.
ryan_gartner
Bri68
For Beta2.2 please use following trace
<switches>
<add name="WorkflowTraceToDefault" value="1" />
<add name="Host" value="All" />
<add name="Runtime" value="All" />
<add name="Tracking" value="All" />
<add name="Activity" value="All" />
<add name="Rules" value="All" />
</switches>
DavidHanlon
I am not calling TryUnload() now.
But I am not able to see the data in InstanceState table. Can you tell me why it is so I have done everything needed. The trace says it has persisted.
Ajil
Mariah Macney
Without using the seperate method for UnLoad() if I use UnLoad() in the calling method, no exception happens but there is no data seen on the database.
Please help
static void OnWorkflowIdled(object sender, WorkflowEventArgs e){
Console.WriteLine("Workflow is idle.");e.WorkflowInstance.TryUnload();
}
Regards
JB-Bellevue
Are you still calling TryUnload If so, why
Any persisted instance should be in the InstanceState table.
Amudhan Elango
If you have set UnloadOnIdle flag in the SqlWorkflowPersistenceService to true, there is no need to call TryUnload explicitly. Workflow will persist and unload automatically after delay starts executing.
At what point are you checking the database As I mentioned if your workflow completes or terminates, workflow state stored in the database will be deleted. Subscribe to the WorkflowPersisted event on the WorkflowRuntime and put a breakpoint in the handler. After your breakpoint is hit, check the "InstanceState" table in the database and you should see the persisted workflow state. Another option is to enable tracing and see if there is a trace for Workflow Persisted event.
For tracing workflow execution, create a app.config file for your host application and add the following text to it. Run your workflow and see the trace in WFTrace.log file
<configuration>
<system.diagnostics>
<switches>
<add name="System.Workflow LogToTraceListeners" value="1" />
<add name="System.Workflow.Runtime.Hosting" value="All" />
<add name="System.Workflow.Runtime" value="All" />
<add name="System.Workflow.Runtime.Tracking" value="All" />
<add name="System.Workflow.Activities" value="All" />
</switches>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="customListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="WFTrace.log" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Harsh Vangani
There are 2 other overloaded constructors in SqlWorkflowPersistenceService that you can use to set the UnloadOnIdle flag.
The signatures are:
public SqlWorkflowPersistenceService(NameValueCollection parameters)
public SqlWorkflowPersistenceService(string connectionString, bool unloadOnIdle, TimeSpan instanceOwnershipDuration, TimeSpan loadingInterval)
Using the NameValueCollection constructor:
NameValueCollection sqlParams = new NameValueCollection();
sqlParams.Add("ConnectionString", "your connection string");
sqlParams.Add("UnloadOnIdle", true);
SqlWorkflowPersistenceService persistService = new SqlWorkflowPersistenceService(sqlParams);
_Vignesh
Gary DeReese
I used the below given code to invoke the Unload().
static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
{
Console.WriteLine("Workflow is idle.");
//Events that are raised back onto a workflow from a runtime event handler need to be queued on the ThreadPool.
//This is because the instance is locked by the runtime engine, and directly raising an event back to the workflow // may cause a deadlock. ThreadPool.QueueUserWorkItem(UnloadInstance, e.WorkflowInstance);}
But while invoking it gives the exception:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Workflow.Runtime.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>IssueTitleApplication.vshost.exe</AppDomain><Exception><ExceptionType>System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Workflow with id "56a96c66-62d0-4677-b7d1-6a5f42e25ae4" not found in state persistence store.</Message><StackTrace> at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTime timeout)
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.WorkflowInstance.TryUnload()
at IssueTitleApplication.Form1.UnloadInstance(Object workflowInstance) in D:\DOT-NET\Projects\Solution1MP\IssueTitle\IssueTitleApplication\Form1.cs:line 137
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)</StackTrace><ExceptionString>System.InvalidOperationException: Workflow with id "56a96c66-62d0-4677-b7d1-6a5f42e25ae4" not found in state persistence store.
at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTime timeout)
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.WorkflowInstance.TryUnload()
at IssueTitleApplication.Form1.UnloadInstance(Object workflowInstance) in D:\DOT-NET\Projects\Solution1MP\IssueTitle\IssueTitleApplication\Form1.cs:line 137
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)</ExceptionString></Exception></TraceRecord>
Kevin_H
I subscribed to WorkflowPersisted event. Gave a Console.WriteLine() method there, I do not see that getting fired.
.NetAvoider
When are you doing an unload If your workflow has a delay or an event and if you have set UnloadOnIdle flag in SqlworkflowpersistenceService to true, your workflow will be persisted in the database while executing delay or event.
One thing to note is if the workflow completes or terminates it is removed from the database.
Please see if the persistence samples in "\Windows Workflow Foundation\Samples\Technologies\Hosting" section are working on your system
Glennpd
It said MSDTC on server 'COL-HAVADT-02' is unavailable. Then I started the DTC service. It became alright. It says it has Persisted the Workflow. But I am not able to see any data in the tables.
Please help.
Regards
Ravi Shanmugam
My code does some thing like this.
String connectStr = "server=COL-HAVADT-02;database=MASTER;Integrated Security=SSPI";sql =
new SqlWorkflowPersistenceService(connectStr);_runtime.AddService(sql);
_runtime.StartRuntime();
-----
-----
_wi = _runtime.CreateWorkflow(_wt, prms);
_wi.Start();
_wi.TryUnload();or
_wi.UnLoad();
Please help.
Regards