5

I have upgrade to GlassMapper version 4.0.1.8 and I'm experiencing strange behavior with some model properties.

All my models are generated by TDS and most of them work fine. On one model Glass Mapper threw a null-reference exception on one specific property and all properties in the base-models. After settings lazy-loading to false for all properties of the model, the issue disappeared...

However, after that I set the SitecoreFieldSettings.DontLoadLazily on all my model properties, since they all are generated by TDS, but now another property of a different model is giving me the same exception and this property is also not lazyloaded.

This is the exception:

Exception: System.NullReferenceException 
Message: Object reference not set to an instance of an object. 
Source: Glass.Mapper 
at Glass.Mapper.AbstractService.InstantiateObject(AbstractTypeCreationContext abstractTypeCreationContext) 
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateConcrete.LazyObjectInterceptor.Intercept(IInvocation invocation) 
at Castle.DynamicProxy.AbstractInvocation.Proceed() 
at Castle.Proxies.ListitemLinkProxy.get_Link() 
at ASP._Page_Views_MyProject_Pages_MyPage_cshtml.Execute() in c:\mycode.cshtml:line 86 
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() 
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) 
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) 
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) 
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) 
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) 
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) 
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) 

1) Why does Glass mapper throws this exception on some fields if they are lazyloaded?

2) Why am I getting the same exception on a different field which is not lazy loaded after lazy-loading the fields of the first model?

Martijn van der Put
  • 4,062
  • 1
  • 18
  • 26
  • This looks like a bug, could you log this on Github and send me an example a model that is throwing the exception? – Michael Edwards Jun 22 '15 at 08:57
  • I will do that in a few days, I need some time to reproduce it and my models consist of several (base) models divided over several projects (this is a multisite solution) so I need to extract that from my project. – Martijn van der Put Jun 25 '15 at 11:23
  • Did this end up getting logged as a bug? We are seeing the same thing. – Wesley Lomax Jul 09 '15 at 16:19
  • 1
    Not yet, I was busy with other parts of the project and did not yet reproduce it. I did find out that I had a field in my Sitecore datatemplate that was called "Image" and it made TDS link image fields to the wrong class instead of the Glass.Mapper.Sc.Fields.Image. That might have been my issue, but I still need to revert some changes and reproduce. – Martijn van der Put Jul 11 '15 at 16:57
  • We've also noticed the names of fields are important. for instance it's not a good idea to give the same name to the template, field section and field itself. – Ruben Verschueren Oct 27 '15 at 10:18

0 Answers0