1

Getting occasional error on glass 4.5.0.4 on Sitecore 9.

"Page editing error. Could not find property **** 
on type ****BaseItemModel at Glass.Mapper.Utilities.GetGlassProperty.... at 
Glass.Mapper.Sc.GlassHtml.MakeEditable..."

Rebooting the server fixes the issue.

Most of the time appears to be working, but sometimes having deployed to an environment when loading experience editor get this issue, and require to reboot the server. Could be a race condition on what glass template map gets loaded first, or a caching issue.

Anyone seen this error?

We weren't seeing this issue on the older version of Glass 4.3.4.197 on Sitecore 8.2.

Here is the base class

    [SitecoreType(AutoMap = true)]
    public class BaseItemModel
    {
        [SitecoreId]
        public virtual Guid ItemId { get; set; }

        [SitecoreInfo(SitecoreInfoType.TemplateId)]
        public virtual Guid TemplateId { get; set; }

        [SitecoreInfo(SitecoreInfoType.TemplateName)]
        public virtual string TemplateName { get; set; }
    }

View:

@inherits GlassView<******.MyViewModel>

@using (BeginEditFrame("*******EDITFRAMEPATH",  Html.Sitecore().CurrentRendering.DataSource, "Title"))
{
<div>
@Editable(x => x.MyProperty***)
</div>
}

2 Answers 2

1

We worked this out in the end. The issue is some of our models were not added to Glass at startup through GlassMapperScCustom.GetGlassLoaders. In editing mode when someone calls Editable in a view it calls GetTypeConfigurationFromType, which has this:

      var config = TypeConfigurations.ContainsKey(type) ? TypeConfigurations[type] : null;

       if (config != null) return config as T;

       if (checkBase && type.BaseType != null)
       {
           //check base type encase of proxy
           config = TypeConfigurations.ContainsKey(type.BaseType) ? TypeConfigurations[type.BaseType] : null;
       }

So it checks the base class if it cant find the type configuration (which initially it doesnt as its not loaded at startup). If the base class also isnt there it uses the OnDemandLoader to add it in to the type configurations, and next time its loaded the first check succeeds. Somewhere else obscure in our code base we were also loading the base model as a standalone model, which also adds it into the type configurations.

On startup, if one or our users did this action which loaded the base type, the next time the parent models where accessed the base check in GetTypeConfigurationFromType now succeeds, which causes the error.

The solution for us is to make sure all models are loaded into Glass on startup and not rely on the OnDemandLoader to add them in.

1
0

My best guess is that the ASP.NET temporary cache isn't being refreshed properly. You could see if this is the issue by deleting the folder C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root next time it occurs and recycling the app pool.

3
  • recyling the app pool fixes it (until the next time it happens), a page will be working fine, and sometimes when request it will get this error until recycle app.
    – Ian
    Commented Sep 11, 2018 at 18:11
  • slight oddity with this setup, both the domain model and view model inherit BaseItemModel. Glass attributes on BaseItemModel and Domain model, Controller uses viewmodel builder to create viewmodel. Glass view references view model.
    – Ian
    Commented Sep 11, 2018 at 18:18
  • Can't explain though why was working in previous version of glass on sitecore 8, and why normally works, but then seems to cache trying to find property on base class.
    – Ian
    Commented Sep 11, 2018 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.