ContentPicker2 error when website is not yet started
Hey,
I use a PartialView on my "Home"-page. This partial uses a ContentPicker2 value to add a link. This is pretty basic acutally:
@if(CurrentPage.HasValue("slideLink")) {
var link = CurrentPage.GetPropertyValue<IPublishedContent>("slideLink");
<a href="@link.Url" class="btn slide-button">
@CurrentPage.GetPropertyValue("slideLinkText")
</a>
}
This works as expected. We noticed that the 2nd line sometimes throws an exception. Everytime the application pool is recycled, or the website is restarted this script crashes.
Error Message from the log:
System.ArgumentException: Ein Element mit dem gleichen Schlüssel wurde bereits hinzugefügt.
bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
bei Umbraco.Core.Services.IdkMap.Populate(IEnumerable`1 pairs, UmbracoObjectTypes umbracoObjectType)
bei Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.EnsureIdkMap(UmbracoContext umbracoContext)
bei Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetById(UmbracoContext umbracoContext, Boolean preview, Guid nodeKey)
bei Umbraco.Web.PublishedCache.ContextualPublishedContentCache.GetById(Boolean preview, Guid contentKey)
bei Umbraco.Web.PublishedContentQuery.TypedContent(Guid id)
bei Umbraco.Web.PublishedContentQueryExtensions.TypedContent(ITypedPublishedContentQuery contentQuery, Udi id)
bei Umbraco.Web.PropertyEditors.ValueConverters.ContentPickerPropertyConverter.ConvertSourceToObject(PublishedPropertyType propertyType, Object source, Boolean preview)
bei Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedProperty.get_Value()
bei Umbraco.Web.PublishedPropertyExtension.GetValue[T](IPublishedProperty property, Boolean withDefaultValue, T defaultValue)
bei Umbraco.Web.PublishedContentExtensions.GetPropertyValue[T](IPublishedContent content, String alias)
bei System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
bei ASP._Page_Views_Partials_Home___Fullsize_Video_with_Slider_cshtml.Execute() in c:\lundp.de\Views\Partials\Home - Fullsize Video with Slider.cshtml:Zeile 30.
bei System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
bei System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
bei System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
bei Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
bei System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
bei ASP._Page_Views_Home_cshtml.Execute() in c:\lundp.de\Views\Home.cshtml:Zeile 22.
bei System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
bei System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
bei System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
bei Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
bei System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
bei System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
bei System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
bei System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
bei System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
bei System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
bei System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
bei System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
bei System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
bei System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
bei System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
As soon as I reload the site, the script works again and no error is thrown.
This happens for all usages of the ContentPicker2 that our site is using.
Per default, the EnablePropertyValueConverter of given UmbracoSite is set to false. Changing it to true didn't have any effect.
ContentPicker2 error when website is not yet started
Hey,
I use a PartialView on my "Home"-page. This partial uses a ContentPicker2 value to add a link. This is pretty basic acutally:
This works as expected. We noticed that the 2nd line sometimes throws an exception. Everytime the application pool is recycled, or the website is restarted this script crashes.
Error Message from the log:
As soon as I reload the site, the script works again and no error is thrown.
This happens for all usages of the ContentPicker2 that our site is using. Per default, the EnablePropertyValueConverter of given UmbracoSite is set to false. Changing it to true didn't have any effect.
Does someone have an idea what is causing this?
Please, use this code:
Hi Chris
Did you solve the issue? Can you share with our community?
Alex
Hey Alex,
thanks for your reply but I couldn't find the time to look into this and test your suggestion. Will try to test this as soon possible.
Chris
Edit:
Above solution works. Thanks again!
is working on a reply...