I am using SharePoint 2013, VS2013 and Workflow engine 4.5. I have a custom Application page that I use for the next step in my workflow process. One the buttons on this page is a cancel button. When my users click this, I use ajax to call into my MVC web application. My MVC5.0 application I first update my Entity Framework database record then try to cancel the workflow.
Below is my MVC code. Why am I getting ExecutionEngineException error at this line clientContext.Load(instances); Note: If the take the below code and copy it to a console application it works!
//cancel the workflow
ClientContext clientContext = new ClientContext(baseUrl);
WorkflowServicesManager wfsm = new WorkflowServicesManager(clientContext, clientContext.Web);
WorkflowInstanceService instanceService = wfsm.GetWorkflowInstanceService();
WorkflowInstanceCollection instances = instanceService.EnumerateInstancesForListItem(listId, itemId);
**clientContext.Load(instances);**
clientContext.ExecuteQuery();
foreach (WorkflowInstance instance in instances)
{
if (instance.Id == new Guid(instanceId))
{
instanceService.CancelWorkflow(instance);
}
}
Any help would be appreciated.
Marek:
I have opened a case with Microsoft (MS). Initial response they gave is that their are know security and other issues with SharePoint and MVC5. I tried using a SharePoint WCF Service project ad got same result. I'll let you know what i find out when MS responds. As for Fiddler, I tried that but it didn't tell me much or maybe I was not interpreting the results correctly. I really thought if I provided explicit credentials (same as the console app that works) but got same error.