Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore PageEditor randomly shows error with Glass.Mapper

I sometimes receive an error when I open 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 item ID. Ensure that at least one property has been marked to contain the Sitecore ID. Type: Castle.Proxies.IBasicPageProxy at Glass.Mapper.Sc.Configuration.SitecoreTypeConfiguration.ResolveItem(Object target, Database database) at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression'1 field, Expression'1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer)

This appears in the place of the rendering, so it doesn't show up as a standard ASP error.

Restarting IIS solves this, but soon it appears again..

I use interfaces for model definitions, with every single 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 use Sitecore 7.5 rev. 141003 (.NET 4.5, MVC5), and the latest versions of Glass.Mapper related NuGet packages 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 issue appears on all machines we tried, but all of them uses Windows 8, IIS 8.5.9600. I tried reverting to the WebActivator method, but it didn't help. Model definitions are in a separate class library project, which references all glass mapper assemblies.

I'm pretty clueless, never run into this error before on other projects. Does anyone have any idea what can cause this, or how I could debug it?

Thank you for your help!

like image 872
Zenima Avatar asked Nov 26 '22 06:11

Zenima


1 Answers

I have put below code in my model and it works

[SitecoreId]
public virtual Guid Id { get; set; }
like image 190
harsh anand Avatar answered Dec 18 '22 23:12

harsh anand