正在安装 Glass.Mapper

Installing Glass.Mapper

我需要安装什么包才能为 Sitecore 8.1 和 VS2013 以及使用 NuGet 的 MVC 5.2.3.0 设置 Glass.Mapper?我已经有 Castle.Windsor.

我单独尝试了 Glass.Mapper.Sc,单独尝试了 BoC.Glass.Mapper.Sc.Mvc-5,同时尝试了两者,我总是得到 运行在 Sitecore 中打开内容编辑器时出现时间错误 UI:

Method not found: '!!0 Glass.Mapper.Context.GetTypeConfiguration(System.Type, Boolean, Boolean)'.

还有其他解决方案项目需要哪些?

更新1: 我不得不去 sitecore bin 文件夹删除所有 Glass.Mapper 相关的 DLL(来自以前的包安装尝试),然后再次安装 Glass.Mapper.Sc。现在我可以打开内容编辑器,但是我在发布时遇到错误:

Could not resolve type name: Glass.Mapper.Sc.ContentSearch.LuceneProvider.GlassDocumentMapperObjectFactory, Glass.Mapper.Sc.ContentSearch.LuceneProvider (method: Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)).

所以我安装了 Glass.Mapper.Sc.ContentSearch.LuceneProvider,但后来我遇到了另一个与 Glass.Mapper 的 Castle.Windsor 版本相关的错误,所以我安装了 Glass.Mapper.Sc.CastleWindsor。 现在,当我点击发布时,我得到以下信息:

Could not resolve type name: Glass.Mapper.Sc.Events.PublishEnd.GlassCacheClear, Glass.Mapper.Sc (method: Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)).

我们在与您相同的环境中使用 GlassMapper 4.0.5.54。 您不需要使用 Boc.Glass.Mapper.Sc.Mvc

在packages.config我们有

<package id="Glass.Mapper.Sc" version="4.0.5.54" targetFramework="net45" />

要安装特定版本,您可以使用命令行:

安装包 CGlass.Mapper.Sc - 版本 4.0.5.54

值得去glass website and viewing tutorials。引用链接页面:

Before install Glass.Mapper.Sc you need to reference the following assemblies in your project:

  • Sitecore.Kernel.dll
  • System.Web.Mvc.dll

Both these files can be found in the bin folder of your Sitecore solution. These assemblies are used to determine which version of the Glass.Mapper assemblies should be referenced.

Once you have added the references above to your project you can download Glass.Mapper.Sc from Nuget. Open the Nuget Package Manager and search for Glass.Mapper.Sc:

Glass.Mapper.Sc V4 Nuget Package in Package Manager

The Nuget package will add references to the Glass.Mapper.dll, Glass.Mapper.Sc.dll, Glass.Mapper.Sc.Mvc.dll and Castle.Core.dll:

V4 Reference add to Project

The Nuget package also install some additional CS files and config files:

Glass.Mapper.Sc V4 Files added to Project

You are now ready to start working with Glass.Mapper. Tutorial 2 will show you how to create your first model.

我通过注释掉解决了

<handler type="Glass.Mapper.Sc.Events.PublishEnd.GlassCacheClear, Glass.Mapper.Sc" method="ClearCache">; 

lass.Mapper.Sc.config 文件中。

祝你好运。