Posted on:
Categories: SharePoint
Description:

Scenario

When you click on the TimeSheet link in Project Server 2013 an error is shown.

Solution

  1. ULS Logs showed the following stack trace:
    1. [bucketHash:3754B72C] Exception occured in method 'TimeSheet.CreateTimesheet' System.ArgumentException: An item with the same key has already been added.
      at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
      at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
      at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.EventHandlerConfiguration.GetInstance(ProjectSite projectSite)
      at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents..ctor(ProjectSite projectSite)
      at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.<>c__DisplayClass8.<GetInstance>b__7()
      at Microsoft.Office.Project.Server.Utility.LazySet`2.GetValue(TKey key, Func`1 instanceFactory)
      at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.GetInstance(Guid siteUid)
      at Microsoft.Office.Project.Server.Events.ServerEventManager.<GetServerEventManager>b__0(IPlatformContext context)
      at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
      at Microsoft.Office.Project.Server.Events.ServerEventManager.GetServerEventManager(IPlatformContext platformContext)
      at Microsoft.Office.Project.Server.BusinessLayer.TimeSheet.CreateTimesheet(TimesheetDataSet dsDelta, PreloadType preloadType)
      at Microsoft.Office.Project.Server.Wcf.Implementation.TimeSheetImpl.<>c__DisplayClass45.<CreateTimesheet>b__44()
      at Microsoft.Office.Project.Server.Wcf.Implementation.WcfMethodInvocation.InvokeBusinessObjectMethod(String businessObjectName, String methodName, IEnumerable`1 actions) StackTrace:
      at Microsoft.Office.Project.Server.Native.dll: (sig=874dbfdc-4770-4b1a-81f8-2b3d83ee10e5|2|microsoft.office.project.server.native.pdb, offset=3C1E)
      at Microsoft.Office.Project.Server.Native.dll: (offset=1255D)
  2. Based on the stack trace, I know the issue is that Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.EventHandlerConfiguration.GetInstance() method returns two items with the same id.
  3. Open the code using JustDecompile or Reflector
    1. Issue occurs at the highlighted line, where the code converts eventHandlersDataSet object to a Dictionary with the Key of PSEventID.
    2. TimeSheet1.png
    3. Next, I looked at the ReadEventHandlerAssociations() method to see where it's getting its data from.
      1. The code lead us to a ReadEventReceivers() method.
      2. TimeSheet2.png
      3. This code calls the "MSP_ADMIN_ReadEventReceivers" Stored Procedure and returns a EventHandlersDataSet.
    4. After dissecting the MSP_ADMIN_ReadEventReceivers Stored Procedure, I was able to create the following query:
      1. "SELECT EVENT_ID FROM pub.MSP_EVENT_HANDLERS GROUP BY EVENT_ID"
      2. When I ran this query it showed that Event_ID 95 had two items.
      3. TimeSheet3.png
    5. Removing the AxUtils.ResourceEventsForAxSync Event Handler from the "Server Side Event Handlers" menu in Central Administration resolved the issue.
      1.  TimeSheet4.png