Friday, November 28, 2008

Workflows general debugging issues

VisualStudio crashes while attaching the w3wp.exe process.
While trying to attach the w3wp.exe process related to workflow, visual studio will take more time during the attach process then it will crash and reopen because of some issues. I am not sure yet why the visual studio is crashing with out giving any error. But i was able to resolve the problem by selecting only the "WorkflowCode" option from the "Attach To" select button.

There are more than one w3wp.exe. which one i should use?
The other issue generally we face is there will be more than on w3wp.exe processes will be showing and it will be confusing which one we should choose. We need to select the process which is showing "Workflow" in the Type section. If none of the processes are displaying "Workflow" in the Type section then it means that the appropriate process is not running. We can't debug by attaching to other w3wp.exe processes.

Couldn't find the process to attach the worflow.
The correct w3wp.exe process to attach the workflow will be showing "Workflow" in the Type column. But some times this will not be displaying due to various reasons. If we want to get the process again in the Attach window , We need to start a workflow manually. Then, the process related to the workflow will be available.

BreakPoints specified in the code file will not work (will not be hit during debug mode).
After specifying the break points in the code, the break points will not be enabled to debug and it will be showing the error "No symbols have been loaded for this document". The issue will be happening because of the following general mistakes.
  • Correct version of the DLL is not deployed to GAC
  • Correct version of the file is not specified in the config files like workflow.xml
  • The Project is build again after the deploying the DLL to GAC
  • There are some modifications done in the code file after the deployment

There is one more issue happening while attaching the process. The break points will be still showing like they will not be hit. (with the "No symbols have been loaded for this document". warning). But if we start debugging after attaching the process with the above error, this error will disappear once the workflow started running and our break points will be hit.

Failed on start - workflow error

I was trying to create a basic workflow with one single "LogtoHistory" activity. But when i tried to start that workflow after associating it with a List. It was failing with the error message "Failed on start"

I tried to debug it after attaching it with the w3wp.exe process. But it was not hitting the break points and the break points were saying the error message
"No symbols have been loaded for this document."
This gave me a clue about the error. I checked the assembly information in the workflow.xml file and found that schema i used to create the workflow.xml put the version of the assembly as 3.0.0.0 . I changed it to correct version and executed the workflow again. It worked fine.

So, If the workflow is failing with "Failed on start" it means there is some mismatch in the assembly information. But if the workflow is giving the error "Failed on Start (Retrying)" there may be some other issues.

This form cannot be opened. It is not workflow enabled

I was creating one workflow with simple Association and Task InfoPath forms. Then deployed the workflow as Feature with all the required InfoPath forms with proper workflow.xml settings.
But whenever i tried to associate the workflow with a custom list. The InfoPath form specified for association opened with the following error message as a pop up.
"This form cannot be opened. It is not workflow enabled"
Then it displayed the "The form is closed" message in the screen.

I checked all kind of settings available in the InfoPath form template and couldn't find any settings related to workflows. I also checked the browser compatibility settings, form ids and even the connection libraries used. But nothing worked out...

Finally i was able to fix the problem only by ..
  • Create a new copy of InfoPath forms from the form templates.
  • Deleted the existing form templates.
  • Renamed the newly created copies of the template to earlier name.
  • Deleted all the published versions of the form
  • Re-published the forms to a new locations with new form Ids
  • Pasted the newly published form in the feature folder
  • Changed the form Ids in the workflow.xml
I checked the settings again it was having the same settings as earlier. But this time the Association InfoPath form opened correctly without any error. Still i am not clear about what caused the error mentioned earlier.

Type 'Microsoft.SharePoint.SPListItem' is not marked as serializable."

I was creating one SharePoint sequential workflow which will create a task and will be in "InProgress" status until the task is completed. But while changing the task i was seeing a weired behaviour of the workflow. It completed automatically with "Completed" status even though the task is not marked as completed. It also logged an error in the workflow history list which was not actually gave me any clue to proceed further. Following was the error message..

"Type 'Microsoft.SharePoint.SPListItem' in Assembly 'Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' is not marked as serializable."

After checking the code inside the "OnTaskChanged" activity. I tried the following code change.

Commented the below explicit variable declaration
//private SPListItem taskValue;

Changed the below line from
taskValue = workflowProperties.Web.Lists["Tasks"].GetItemById(onTaskChanged1_AfterProperties1.TaskItemId);
To
SPListItem taskValue = workflowProperties.Web.Lists["Tasks"].GetItemById(onTaskChanged1_AfterProperties1.TaskItemId);

It resolved my problem. But don't know yet what the above error is meant to be. I think i am missing some basic understanding here. Still working on it :)

How to find whether a operating system is 32 bit or 64 bit

I had to install one hotfix from microsoft, while downloading i was given different options to downlaod the correct package related to my Operation System. I was using the windows server 2003 operating system.
To find the information in windows server 2003,
  • Click on the MyComputer --->Properties --> General Tab.
  • If the System Name is specified as "Microsoft Windows Server 2003 Enterprise Edition" then it is 32 bit OS.
  • If the System Name is specified as "Microsoft Windows Server 2003 Enterprise x64 Edition" then its 64 bit OS.

Update: I found that there is also a very good article available from Microsoft to find the information for other OS as well. (http://support.microsoft.com/kb/827218)