当我在编辑模式下打开 sitecore 页面时,我遇到了以下错误消息。任何想法似乎是什么问题。
我使用的是 Glass mapper fluent 配置,它适用于其他一些类。问题似乎只有一门课,我无法找出导致问题的原因。任何帮助,将不胜感激。
8384 13:46:48 错误无法在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] 参数,Object [] arguments) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfoculture) 在 System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) 在 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) `嵌套异常异常:System.Collections.Generic.KeyNotFoundException 消息:字典中不存在给定的键。来源: Sitecore.ContentSearch.SearchTypes.SearchResultItem.get_Item(String key) 的 Sitecore.ContentSearch.ContentSearch.SearchTypes.SearchResultItem.get_Version()
导致问题的代码。
查看渲染:
@using Glass.Mapper.Sc.Web.Mvc
@inherits GlassView<_RegionsCMS.Presentation.Models.InsightBaseModel>
<div class="nav-container">
<div class="page-nav" role="navigation">
<h1 class="article-title">@Editable(model => model.Insight.Title)</h1>
</div>
控制器定义:
var insight = _sitecoreContext.GetCurrentItem<Insights>();
var model = new InsightBaseModel
{
Insight = insight
};
return View(model);
洞察类定义:
public class Insights : SearchResultItem {
//Basic Information
public virtual string Title { get; set; }}
流畅的配置:
public static IConfigurationLoader[] GlassLoaders(){
var attributes = new AttributeConfigurationLoader("Glass.Mapper.Sc");
var loader = new SitecoreFluentConfigurationLoader();
var config = loader.Add().AutoMap();
config.Id(x => x.ItemId);
config.Info(x => x.Language).InfoType(SitecoreInfoType.Language);
config.Info(x => x.Version).InfoType(SitecoreInfoType.Version);
config.Info(x => x.Url).InfoType(SitecoreInfoType.Url);
return new IConfigurationLoader[] {attributes ,loader };
}