5

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!

Liam
  • 27,717
  • 28
  • 128
  • 190
Zenima
  • 380
  • 2
  • 14

2 Answers2

1

I have put below code in my model and it works

[SitecoreId]
public virtual Guid Id { get; set; }
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • 1
    While this code may solve the problem, a few words of explanation would go a long way to making this answer valuable to future readers. – Thom Apr 30 '15 at 17:11
  • The OP has already effectively done this, I don't believe this is the solution – Liam Oct 13 '15 at 12:52
-2

Glass mapper requires Item to be represented by a ID. If the glass model does not have a property for GUID, you will see this error.

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