Internal Error: An item with the same key has already been added

I am getting an internal error when I try to publish my application (An item with the same key has already been added).  I've tried to do a "Refresh All" within Manage Dependencies, but this does not resolve the issue.


Following is the full stack trace


Internal Error
An error occurred in task 'Loading eSpace with key '6cd8ed7f-a3d9-4ed3-9642-03b863930038'':
An item with the same key has already been added.
Details : 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 OutSystems.HubEdition.Compiler.Reference.CompiledReference.StoreCurrentOriginalName(IUserVisibleReferenceElement obj)
   at OutSystems.HubEdition.Compiler.ReferenceStaticRecord.set_CurrentOriginalName(String value)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.FillChildrenCurrentOriginalNames(AbstractObject currentObj, IUserVisibleReferenceElement currentOriginalElement)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.UpdateReferenceElementsOriginalNames(Dictionary`2 allReferenceElementsForThisReference)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.CheckReferencesAfterLoad(ESpace eSpace, Boolean updateDB, Int32 consumerVersionId, HashSet`1 modulesWithMissingIndirectRefs, Dictionary`2 producerElementsExternalDependencies, Dictionary`2 originalCompatibilitySignatureHashes)
   at OutSystems.HubEdition.Compiler.ESpace.AfterLoad()
   at OutSystems.HubEdition.Compiler.ESpace..ctor(Oml oml, CompilationContext context, Boolean loadModelOnly)
   at OutSystems.HubEdition.Compiler.Compiler.LoadEspace(CompilationContext context, HEMessageArrayList& messages, Byte[] fullOml, Byte[] partialOml, Boolean allowInvalid)
   at #XWb.#XYb.InnerExecute(IESpace& eSpace)
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask`3.InnerExecute()
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask.Execute()
Exception Details:
[1] Internal Error: An error occurred in task 'Loading eSpace with key '6cd8ed7f-a3d9-4ed3-9642-03b863930038'':
An item with the same key has already been added.
Details : 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 OutSystems.HubEdition.Compiler.Reference.CompiledReference.StoreCurrentOriginalName(IUserVisibleReferenceElement obj)
   at OutSystems.HubEdition.Compiler.ReferenceStaticRecord.set_CurrentOriginalName(String value)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.FillChildrenCurrentOriginalNames(AbstractObject currentObj, IUserVisibleReferenceElement currentOriginalElement)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.UpdateReferenceElementsOriginalNames(Dictionary`2 allReferenceElementsForThisReference)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.CheckReferencesAfterLoad(ESpace eSpace, Boolean updateDB, Int32 consumerVersionId, HashSet`1 modulesWithMissingIndirectRefs, Dictionary`2 producerElementsExternalDependencies, Dictionary`2 originalCompatibilitySignatureHashes)
   at OutSystems.HubEdition.Compiler.ESpace.AfterLoad()
   at OutSystems.HubEdition.Compiler.ESpace..ctor(Oml oml, CompilationContext context, Boolean loadModelOnly)
   at OutSystems.HubEdition.Compiler.Compiler.LoadEspace(CompilationContext context, HEMessageArrayList& messages, Byte[] fullOml, Byte[] partialOml, Boolean allowInvalid)
   at #XWb.#XYb.InnerExecute(IESpace& eSpace)
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask`3.InnerExecute()
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask.Execute()
at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask.Execute()
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask`3.Run(InputType context, IMessageBroker messageBroker, OutputType& result)
   at OutSystems.HubEdition.ServerCommon.Tasks.TaskRunner.Run()
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask.Execute()
   at #h2b.#h3b.#vo.#e9b()
   at OutSystems.HubEdition.ServerCommon.Tasks.TaskRunner.Run()
   at #h2b.#h3b.InnerExecute()
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask.Execute()
   at OutSystems.HubEdition.DeploymentController.Compiler.<>c__DisplayClass154_0.<PublishOml>b__0()
   at OutSystems.HubEdition.DeploymentController.Compiler.PublishOml(Object publishContext)
   at #DSb.#6wb.#VQ.#BFb(Object s)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
[2] 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 OutSystems.HubEdition.Compiler.Reference.CompiledReference.StoreCurrentOriginalName(IUserVisibleReferenceElement obj)
   at OutSystems.HubEdition.Compiler.ReferenceStaticRecord.set_CurrentOriginalName(String value)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.FillChildrenCurrentOriginalNames(AbstractObject currentObj, IUserVisibleReferenceElement currentOriginalElement)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.UpdateReferenceElementsOriginalNames(Dictionary`2 allReferenceElementsForThisReference)
   at OutSystems.HubEdition.Compiler.References.SignatureUtils.CheckReferencesAfterLoad(ESpace eSpace, Boolean updateDB, Int32 consumerVersionId, HashSet`1 modulesWithMissingIndirectRefs, Dictionary`2 producerElementsExternalDependencies, Dictionary`2 originalCompatibilitySignatureHashes)
   at OutSystems.HubEdition.Compiler.ESpace.AfterLoad()
   at OutSystems.HubEdition.Compiler.ESpace..ctor(Oml oml, CompilationContext context, Boolean loadModelOnly)
   at OutSystems.HubEdition.Compiler.Compiler.LoadEspace(CompilationContext context, HEMessageArrayList& messages, Byte[] fullOml, Byte[] partialOml, Boolean allowInvalid)
   at #XWb.#XYb.InnerExecute(IESpace& eSpace)
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask`3.InnerExecute()
   at OutSystems.HubEdition.ServerCommon.Tasks.AbstractTask.Execute()

Hi Ben,

I had this once and fixed it like this

1. Save module as .oml file

2. Remove module 

3. Open .oml file

4. Publish module

Regards,

Daniel



Hi Ben, 

I've seen this also, in class. 

I'll ask you, first, to submit an issue from withing Service Studio, so that the team can take a look. 

In my case, the solution, in one case, was to first merge the mode with the content in the server and only after publish it. 

In another situation was a problem with dependences. I had to publish a producers module first, the theme module, and then refresh the dependences and publish the module again. 

Cheers