Sitecore PageEditor randomly shows error with Glass.Mapper

Sometimes I get an error when opening a page in page editor mode on my Sitecore site using Glass.Mapper.

You cannot save a class that does not contain a property that represents the identifier of an element. Make sure that at least one is flagged to contain the Sitecore ID. Type: Castle.Proxies.IBasicPageProxy in Glass.Mapper.Sc.Configuration.SitecoreTypeConfiguration.ResolveItem (Object target, Database Database) at Glass.Mapper.Sc.GlassHtml.MakeEditable [T] (field Expression'1, Expression'1 standardOutput, T model, Object parameters, Context Context, Database Database, Writer TextWriter)

This appears at the render location, so it does not appear as a standard ASP error.

Restarting IIS resolves this, but it soon reappears.

I use interfaces to define models, with each individual interface inheriting from IBaseType:

[SitecoreType] public interface IBaseType { [SitecoreId] Guid Id { get; set; } [SitecoreInfo(SitecoreInfoType.Name)] string Name { get; set; } [SitecoreItem] Item InnerItem { get; set; } [SitecoreInfo(SitecoreInfoType.Url)] string Url { get; set; } [SitecoreInfo(SitecoreInfoType.TemplateId)] Guid TemplateId { get; set; } [SitecoreInfo(SitecoreInfoType.FullPath)] string FullPath { get; set; } } 

I am using Sitecore 7.5 rev. 141003 (.NET 4.5, MVC5) and the latest NuGet packages related to Glass.Mapper currently:

  • Castle.Windsor 3.3.0
  • Castle.Core 3.3.3
  • Glass.Mapper 3.0.14.26
  • Glass.Mapper.Sc 3.2.3.46
  • Glass.Mapper.Sc.CastleWindsor 3.3.0.24
  • Glass.Mapper.Sc.Mvc-5 3.3.0.43

The problem appears on all the machines we tried, but they all use Windows 8, IIS 8.5.9600. I tried to return to the WebActivator method, but that did not help. The model definitions are in a separate class library project that refers to all glass-collector assemblies.

I am rather ignorant, I have never encountered this error before other projects. Does anyone know what might cause this, or how can I debug it?

Thank you for your help!

+5
source share
2 answers

I put below code in my model and it works

 [SitecoreId] public virtual Guid Id { get; set; } 
+1
source

The glass mapper requires the item to be represented by an identifier. If the glass model does not have a property for the GUID, you will see this error.

You can fix this by adding the public virtual GUID property {get; set;} to your glass model

-2
source

Source: https://habr.com/ru/post/1209575/


All Articles