Received an error from the server
An error occurred
An item with the same key has already been added. Key: pa
Exception Details
System.ArgumentException, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: An item with the same key has already been added. Key: pa
Stacktrace
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at Umbraco.Cms.Web.BackOffice.Controllers.LanguageController.GetAllCultures()
at lambdamethod488(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|250(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
I had an error similar to yours. It turned out to be a problem with some of the naming of properties(Edit: property in one of my document types). If you can find the property name that throw the error you might be able to change it and fix it.
Edit: I'm not saying that there isn't a real problem somewhere in the umbraco code. I just found a workaround by changing the name of a propeerty in one of my document types.
Thanks for your reply, however, the same thing happened when I start over the project and try to add the language before I create anything. I think it's a big issue.
Okay, is there any reason why you use the source files and not just install with dotnot or any of the other installations methods?
I installed a clean version of umbraco 9.0.1 and had no problem with adding a new language.
As Frank mentions the recommended approach is to use the dotnet new templates to install Umbraco, unless you are intending to work on the source code and contribute a PR back to Umbraco.
Please try a clean Umbraco 9.0.1 install using the dotnet new approach and see if you can reproduce the problem.
I followed your first link and start all over again step by step but the result is still the same, even this time I connect to SQL Server (first and second time using LocalDB). Anyway, thanks for your reply.
Where does Umbraco get the list of languages to display in the dropdown from?
is it from those installed on the server?
In this instance that list contains a duplicate culture code of 'pa' by the look of it!
We had similar issue last night, on a site deployed to IIS, but locally (same database) it was ok to add languages, but the error was in listing out the languages... of course as we now have successfully added to them to the project... haven't delved any further... but thought I'd add here in case it helps...
Can add to this that the language list doesn't load on IIS on Server 2012R2, possibly something related to https://github.com/umbraco/Umbraco-CMS/pull/11276 Haven't had a chance to investigate further, sorry!
I grabbed a laptop with Windows 10 Enterprise LTSC ver1809 build 17763.2183, the language in Hong Kong SAR (Traditional Chinese) and it works fine! I think the problem was caused by the Windows version. Can't believe that.
An item with the same key has already been added. Key: pa
... what in infers to me, is something is looping through the available languages (presume from windows) and adding each language to a dictionary, perhaps with the key matching the culture name?
The error is happening when it goes to add a language with key 'pa', but one has already been added with that key and blows up the dictionary...
I can only see 'punjabi-India' code: pa-IN that contains 'pa', but perhaps there is something else in your machine, that is returning an additional pa.
The way to check would be to call CultureInfo.GetCultures(CultureTypes.AllCultures) on the errant machine and see if you get a duplicate 'pa'!
it's calling ToDictionary on the results of GetCultures so will blow up if there are any duplicates or clashing culture code names on the server or machine it is installed on! Would just need to filter out duplicates first.
Hi
I have a question about the described problem. I have Umbraco version 9.1.1 installed on the web hosting provider. (IIS on Windows server) and the described error manifests itself in a different way.
Where is the problem on the provider or umbraco?
Is the described fix already applied or will it be in the next version?
Error occurred when click on Add language V9.0.1
I downloaded the source files from https://umbraco.com/products/umbraco-cms/how-to-download-umbraco/ and put it on Visual Studio 2019 for build and run.
Errors occurred while I was following the tutorial here https://our.umbraco.com/documentation/Tutorials/Creating-Basic-Site/Adding-Language-Variants/. [step 3 Click Add Language]:
Received an error from the server An error occurred An item with the same key has already been added. Key: pa
Exception Details System.ArgumentException, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: An item with the same key has already been added. Key: pa Stacktrace at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector) at Umbraco.Cms.Web.BackOffice.Controllers.LanguageController.GetAllCultures() at lambdamethod488(Closure , Object , Object[] ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|250(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Hi Kenjin
I had an error similar to yours. It turned out to be a problem with some of the naming of properties(Edit: property in one of my document types). If you can find the property name that throw the error you might be able to change it and fix it.
Edit: I'm not saying that there isn't a real problem somewhere in the umbraco code. I just found a workaround by changing the name of a propeerty in one of my document types.
Hi Frank,
Thanks for your reply, however, the same thing happened when I start over the project and try to add the language before I create anything. I think it's a big issue.
Hi Kenjin,
Okay, is there any reason why you use the source files and not just install with dotnot or any of the other installations methods? I installed a clean version of umbraco 9.0.1 and had no problem with adding a new language.
Hi Frank,
This time I used this script to create the project:
dotnet new umbraco --name MyProject
So, I think it's the way you mentioned to install the project.
Hi Kenjin,
As Frank mentions the recommended approach is to use the
dotnet new
templates to install Umbraco, unless you are intending to work on the source code and contribute a PR back to Umbraco.Please try a clean Umbraco 9.0.1 install using the dotnet new approach and see if you can reproduce the problem.
https://our.umbraco.com/Documentation/Fundamentals/Setup/Install/install-umbraco-with-templates
If you can reliably reproduce it then please file an issue on the GitHub issue tracker
https://github.com/umbraco/Umbraco-CMS/issues/new/choose/
Thanks,
Warren 😀
Hi Warren,
I followed your first link and start all over again step by step but the result is still the same, even this time I connect to SQL Server (first and second time using LocalDB). Anyway, thanks for your reply.
Hi Kenjin
So can you tell me what language you are trying to add, to see if I can reproduce this as well.
Cheers,
Warren
Where does Umbraco get the list of languages to display in the dropdown from?
is it from those installed on the server?
In this instance that list contains a duplicate culture code of 'pa' by the look of it!
We had similar issue last night, on a site deployed to IIS, but locally (same database) it was ok to add languages, but the error was in listing out the languages... of course as we now have successfully added to them to the project... haven't delved any further... but thought I'd add here in case it helps...
regards
Marc
Can add to this that the language list doesn't load on IIS on Server 2012R2, possibly something related to https://github.com/umbraco/Umbraco-CMS/pull/11276 Haven't had a chance to investigate further, sorry!
Hi Warren,
Actually, I just click on the "Add language" button and the error happened, I have no luck selecting the language as well.
Click on Add language button:
Error occurred:
No language for select:
Regards,
Thanks a lot
If you set up a freshly install of umbraco and push it to github or another repo hosting I could check if it is something wrong with the installation.
Best regards Frank
Hi Keniin
Thanks for the information, I would be curious to know more about your machine please.
What OS are you using with a version number and what language is the computer set to use ?
As reading Marc's & Jeavon's comment it seems they are having very similar issues when the site is run from a Windows.
Cheers Warren 😀
Hi Warren
I'm using Windows 10 Enterprise LTSC ver1607 build 14393.4651, the language is Hong Kong SAR (Traditional Chinese)
Thanks & Cheers Kenjin
Is it possible for you to change language to english on your machine and test again ?
Best regards Frank
Hi Frank,
I grabbed a laptop with Windows 10 Enterprise LTSC ver1809 build 17763.2183, the language in Hong Kong SAR (Traditional Chinese) and it works fine! I think the problem was caused by the Windows version. Can't believe that.
Regards Kenjin
What I'm intrigued about is the error message...
... what in infers to me, is something is looping through the available languages (presume from windows) and adding each language to a dictionary, perhaps with the key matching the culture name?
The error is happening when it goes to add a language with key 'pa', but one has already been added with that key and blows up the dictionary...
But looking at ISO language codes: https://docwiki.embarcadero.com/RADStudio/Sydney/en/LanguageCultureNames,Codes,andISOValues
I can only see 'punjabi-India' code: pa-IN that contains 'pa', but perhaps there is something else in your machine, that is returning an additional pa.
The way to check would be to call CultureInfo.GetCultures(CultureTypes.AllCultures) on the errant machine and see if you get a duplicate 'pa'!
The fix would then be here in Umbraco:
https://github.com/umbraco/Umbraco-CMS/blob/5bfab13dc5a268714aad2426a2b68ab5561a6407/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs#L53
it's calling ToDictionary on the results of GetCultures so will blow up if there are any duplicates or clashing culture code names on the server or machine it is installed on! Would just need to filter out duplicates first.
regards
Marc
OK Marc & Kenjin Looks like Bjarke has been debugging this with you over on the GitHub issue tracker and has put a fix in place.
https://github.com/umbraco/Umbraco-CMS/issues/11427
https://github.com/umbraco/Umbraco-CMS/pull/11441
ahh, thanks Warren, looks like I was right too!
Hi I have a question about the described problem. I have Umbraco version 9.1.1 installed on the web hosting provider. (IIS on Windows server) and the described error manifests itself in a different way.
Where is the problem on the provider or umbraco? Is the described fix already applied or will it be in the next version?
Thanks
is working on a reply...