Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Christian John Schmidt 9 posts 112 karma points
    Nov 18, 2019 @ 10:13
    Christian John Schmidt
    0

    Nested content "Object reference not set to an instance of an object."

    Hi! I've started to get this error on a fresh installation on Umbraco 8.3:

    Stack trace:

    [NullReferenceException: Object reference not set to an instance of an object.] Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.CreateModelList(String alias) +57 Umbraco.Web.PropertyEditors.ValueConverters.NestedContentManyValueConverter.ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview) +222 Umbraco.Core.Models.PublishedContent.PublishedPropertyType.ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview) +57 Umbraco.Web.PublishedCache.NuCache.Property.GetValue(String culture, String segment) +197 Umbraco.Web.PublishedPropertyExtension.Value(IPublishedProperty property, String culture, String segment, Fallback fallback, T defaultValue) +71 Umbraco.Web.PublishedContentExtensions.Value(IPublishedContent content, String alias, String culture, String segment, Fallback fallback, T defaultValue) +117 ASP.PageViewsindholdcshtml.Execute() in C:\laragon\www\UmbracoTemplate.Core\UmbracoTemplate.Web\Views\indhold.cshtml:13 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) +235 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107 Umbraco.Web.Mvc.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +98 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +290 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +52 System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +198 System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +100 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45 System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +22 System.Web.Mvc.Async.WrappedAsyncResultBase1.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.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28 System.Web.Mvc.Async.WrappedAsyncVoid1.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() +576 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +132 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163


    I'm trying to get a Nested content out as an IEnumerable

    var test = Model.HasProperty("grid"); //Returns true
    var test2 = Model.HasValue("grid"); //Returns true
    var value = Model.GetProperty("grid").GetSourceValue(); //Returns string "[{\"key\":\"aa6faaf8-e554-46d5-9121-ad0314328e8e\",\"name\":\"Item 1\",\"ncContentTypeAlias\":\"textEditor\",\"propertyAlias\":\"asdfasdf\",\"text\":\"
    IEnumerable<IPublishedElement> blocks = Model.Value<IEnumerable<IPublishedElement>>("grid"); // Nullpointer
    

    Can anyone help with this? If you need more info please tell me

    Thanks in advance!

  • Christian John Schmidt 9 posts 112 karma points
    Nov 18, 2019 @ 11:02
    Christian John Schmidt
    0

    In addition Model.Value("grid") also returns null - seems like there's a bug with retrieving the data?

  • Davit 7 posts 88 karma points
    May 06, 2020 @ 18:55
    Davit
    0

    Hi, I have the same issue. Did you find any solution for it Christian?

  • Davit 7 posts 88 karma points
    May 06, 2020 @ 20:21
    Davit
    0

    hi Christian here is my fix

    Install Umbraco.ModelsBuilder from Nuget In web.config you should have next values for Umbraco.ModelsBuilder

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="LiveDll" />
    
  • Danny 4 posts 55 karma points
    Aug 11, 2020 @ 02:32
    Danny
    1

    Hi Everyone, not sure of this is still an issue for others but I found my problem resolution was a little different to other posted. I had made a mistake in my inherited Document Types which caused my issue. I found the root cause by going to the folder [MyProject]App_Data > Models > and inside there was a file called models.err. This file gave me this error info:

    Failed to build PureLive models.
    Cannot generate model for type 'hero' because it is an element type, but it is composed of 'contentBase' which is not.
    
       at Umbraco.ModelsBuilder.Building.Builder.Prepare() in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Building\Builder.cs:line 244
       at Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.GenerateModelsCode(IDictionary`2 ourFiles, IList`1 typeModels) in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\PureLiveModelFactory.cs:line 567
       at Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.GetModelsAssembly(Boolean forceRebuild) in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\PureLiveModelFactory.cs:line 458
       at Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.EnsureModels() in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\PureLiveModelFactory.cs:line 283
    

    I simply fixed my Document Types and all good. I raise this as most other solutions were DLL or Nuget package based and this problem was much simpler. My errors and symptoms were identical but resolution completely different. I hope this helps someone who may be seeing something similar.

    Thanks,

  • Phong Tran 3 posts 73 karma points
    Oct 28, 2020 @ 04:04
    Phong Tran
    0

    Thank @Danny, I have the same problem like you. I remove composition from base document type and it works normally.

  • Harry 8 posts 78 karma points
    Jun 02, 2021 @ 10:14
    Harry
    0

    Thanks, Phong. Spent ages trying to fix this and by removing the composition, it worked for me as well.

Please Sign in or register to post replies

Write your reply to:

Draft