"Server Error in '/' Application. An item with the same key has already been added" on Image after upgrade to 7.10.0
Hi all,
I've just upgraded from Umbraco 7.9.3 to 7.10.0
Now, when I run the project, I get the error below. I've seen this error appear lots on the forum, and it seems to point to a duplicate alias in the doc types, but I've checked, and I don't have any.
Oddly, I only get the error on first load - when I Continue and then refresh the page, I don't get the error. I can then navigate around the site and back to the original page with no errors.
You'll see in the code below that there's a commented out line where I tried just .Url instead of GetCropUrl, but I still got the same error.
I also tried deleting the image from the back-end, and assigning a new image, but I still got the same error.
Any ideas would be appreciated.
Server Error in '/' Application.
An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An item with the same key has already been added.
Source Error:
Line 25: {
Line 26: var image = item.GetPropertyValue<IPublishedContent>("image");
Line 27: var responsiveImage = image.GetCropUrl("Hotspot portrait");
Line 28: //var responsiveImage = image.Url;
Line 29: <a href="@Umbraco.NiceUrl(item.GetPropertyValue<int>("linkURL"))" class="hotspot-item">
Source File: c:\Users\paul\source\repos\PaulMcGSite\PaulMcGSite\Views\Home.cshtml Line: 27
Stack Trace:
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +183
Umbraco.Core.Services.IdkMap.Populate(IEnumerable`1 pairs, UmbracoObjectTypes umbracoObjectType) +319
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.EnsureIdkMap(UmbracoContext umbracoContext) +294
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetById(UmbracoContext umbracoContext, Boolean preview, Guid nodeKey) +40
Umbraco.Web.PublishedCache.ContextualPublishedContentCache.GetById(Boolean preview, Guid contentKey) +71
Umbraco.Web.PublishedContentQuery.TypedContent(Guid id) +158
Umbraco.Web.PublishedContentQueryExtensions.TypedContent(ITypedPublishedContentQuery contentQuery, Udi id) +96
Umbraco.Web.PropertyEditors.ValueConverters.ContentPickerPropertyConverter.ConvertSourceToObject(PublishedPropertyType propertyType, Object source, Boolean preview) +260
Umbraco.Web.Models.DetachedPublishedProperty.<.ctor>b__7_1() +49
System.Lazy`1.CreateValue() +411
System.Lazy`1.LazyInitValue() +152
System.Lazy`1.get_Value() +75
Umbraco.Web.Models.DetachedPublishedProperty.get_Value() +9
Umbraco.Web.PublishedPropertyExtension.GetValue(IPublishedProperty property, Boolean withDefaultValue, T defaultValue) +68
Umbraco.Web.PublishedContentExtensions.GetPropertyValue(IPublishedContent content, String alias) +30
ASP._Page_Views_Home_cshtml.Execute() in c:\Users\paul\source\repos\PaulMcGSite\PaulMcGSite\Views\Home.cshtml:27
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +113
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +290
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9748665
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2633.0
The behaviour is exactly the same: only after the rebuild.
The instruction that generate the error for me is the first (and only the first) Umbraco.TypedContent(someID). When i refresh the page the error's gone.
At the beginning I triple-checked my doctypes looking for a duplicated property and I run a sql to search duplicated alias... nothing.
Can you debug step-to-step and check if the line that generate the error is the 26 and not 27? I also had the wrong line number :D
"Server Error in '/' Application. An item with the same key has already been added" on Image after upgrade to 7.10.0
Hi all,
I've just upgraded from Umbraco 7.9.3 to 7.10.0
Now, when I run the project, I get the error below. I've seen this error appear lots on the forum, and it seems to point to a duplicate alias in the doc types, but I've checked, and I don't have any.
Oddly, I only get the error on first load - when I Continue and then refresh the page, I don't get the error. I can then navigate around the site and back to the original page with no errors.
You'll see in the code below that there's a commented out line where I tried just .Url instead of GetCropUrl, but I still got the same error.
I also tried deleting the image from the back-end, and assigning a new image, but I still got the same error.
Any ideas would be appreciated.
I'd really appreciate some help with this, if anyone's able. Could it possibly be an issue with ImageProcessor?
Thanks!
Hi Paul! Same thing, from 3 or 4 version ago...
The behaviour is exactly the same: only after the rebuild. The instruction that generate the error for me is the first (and only the first) Umbraco.TypedContent(someID). When i refresh the page the error's gone.
At the beginning I triple-checked my doctypes looking for a duplicated property and I run a sql to search duplicated alias... nothing.
Can you debug step-to-step and check if the line that generate the error is the 26 and not 27? I also had the wrong line number :D
S
Hi Stefano,
Thanks loads for replying to my question, I appreciate the help!
Yes, I checked the issue in debug, and this is the line that falls over:
Do you have any idea what might be causing it?
Many thanks,
Paul
Hi Paul,
Okay, so the first 2 things I'd try with this issue would be:
I know you've had the issue for a while now, but in case you've not tried those I thought I'd suggest them.
Nik
Looks like we've identified the underlying issue which hopefully should be fixed very soon: http://issues.umbraco.org/issue/U4-11208
Thanks everyone for the help and feedback.
I've tried removing the image and reloading it, but even when I switched it out for a different image, I got the same error at the same point.
So I wonder if Sebastiaan's patch is the way forward - it looks like it is.
Is there a simple way for me to apply the patch so I don't have to wait for the next Umbraco release?
If you're able to tell me what to change, and where, that would be fantastic!
Thanks again
Release will be out Tuesday :)
That is totally awesome. Thank you so much!
Just installed the 7.10.4 update - bug gone, it worked perfectly.
Thank you!
is working on a reply...