Microsoft Dynamics AX Support

This blog contains posts by the Microsoft Dynamics AX Support Teams Worldwide

SSRS error in AX2012 – An item with the same key has already been added

Recently came across this issue which was that a particualr report would no longer run -at all. Everytime you run it an error is recorded in the SSRS error log (default location is: C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\LogFiles) that looks something like this:

webserver!ReportServer_0-12!598!03/01/2012-17:57:57:: e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.RSException: An error has occurred during report processing. —> Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: An error has occurred during report processing. —> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Query execution failed for dataset ‘PurchPurchaseOrderDS’. —> System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.Dynamics.Framework.Reports.SetQueryProjectionVisitor.ProcessQueryFieldMetadata(AxQuerySchemaAnalysisElement fieldElement, QueryFieldMetadata queryField)

I have cut the error short here as it was pretty long, but this top part is the interesting part –  basically the call stack that is shown here, this is a report being run trying to build metadata caches, specifically lists of enum values or similar. It fails here trying to insert a duplicate into a list. We didn’t know exactly which enum/ist as we didn’t need to get as far as debugging this component.

Redeploying the report here resolved the issue. Before redeploying we had already restarted the AOS that was providing the WCF services for SSRS – but it made no difference.

So from this we can deduce that it wasn’t AOS cache, or SSRS cache causing the failure – redeploying the report resolved it therefore the report metadata deployed to SSRS is likely to have been out of step with the related objects in the AOT, redeploying brought everything back into line and no more problem.