Aug 30, 2012

Debugging an SPTimerJob

Here's a checklist to run through if you're having problems debugging an SPTimerJob:

1. Make sure your Visual Studio debugger is attached to OWSTimer.exe
2. If you've updated the DLL for your SPTimerJob, you must restart the SharePoint Timer service.
3. Don't run the job using the "Run now" option in the Timer Definition page; instead program your job for a 1 minute interval and let the service run the job itself.

Aug 9, 2012

An exception occurred while enqueueing a message in the target queue. Error: 15404, State: 19. Could not obtain information about Windows NT group/user , error code 0x5

If you get this error with SharePoint and SQL Server filling up your SQL logs, try the following:

1. Check which user account is configured as the Service Account for your SQL Server instance.

2. Confirm in your Active Directory that the security object "NT Authority\Authenticated Users" have Read permission on your service account.  
  a.  Open  "Active Directory Users & Computers" on a Windows Server with admin permissions
  b. Active "Advanced features" in the View menu
  c. Right click the service user account and choose Properties
  d. Go to the Security tab and click on "Authenticated users" (If it doesn't exist, add it)
3. If the account is NTAuthority\NetworkService, change it to a regular domain account "yourdomain\yoursqlserviceuser" and restart the SQL Server service

4. Change the service account back to NTAuthority\NetworkService and restart the SQL Server service

5. Check if the error still appears.

Important:  The best practice is to use a regular domain account as the service account for SQL Server to avoid problems such as SQL backups across networks.

Aug 2, 2012

Running child activities in a custom SharePoint Designer activity

I ran into the simple question of how to run child activities I had dragged into my custom SequenceActivity.  I naively assumed they would run automatically but that's not the case.

1. Drag and drop activities into your custom activity (Sharepoint or standard WWF activities)
2. In the Execute method you override, call the context.ExecuteActivity method on each child activity in the EnabledActivities collection.
3. Bind to at least one close event for a child activity in order to be able to close the parent activity.
4. In the Execute method, set the context.ExecutionStatus to Running.

There are more details in the example from MSDN:

Aug 1, 2012

Output parameter in a custom Sharepoint Designer activity

If you're having trouble with an output parameter in a custom SharePoint Designer activity, check the following:

  • DesignerType="ParameterNames" in the FieldBind element in the .actions file
  • Direction="Out" in the Parameter element in the .actions file
And when you're sure everything is correct and your activity shows up in the SPD menu but doesn't do anything upon insertion, clear your SPD DLL cache:

In Windows 7, the path to the WebSiteCache folder is "C:\Users\yourUserName\AppData\Local\Microsoft\WebsiteCache"