Having Issues while using Glass.Mapper with Sitecore 9? Here we Go…

Version Details:

Sitecore Experience Platform 9.0 rev. 171219 (9.0 Update-1) and Glass.Mapper


Issue Background:

We have recently upgraded to Sitecore 9 Update 1 from Sitecore 8.1 Update 3. And then we upgraded the Glass.Mapper to it’s latest stable version and started getting error “Method not found – Boolean PageMode.get_IsPageEditor()”, which appeared to be more stubborn than I initially thought it would be. Then I had thoughts on its compatibility with Sitecore 9, and could get enough evidence to believe that it should definitely work with SC 9. Compatibility Chart of Glass clearly shows that: Glass Compatibility Chart . And also, I have found blogs such as: https://sitecoresandbox.com/2017/11/08/glass-mapper-experience-editor-issue-with-sitecore-9/ and http://www.sitecorebear.com/glass-mapper-and-sitecore-9/, which shows Glass.Mappers previous beta version works with SC 9.

Even after trying multiple stuffs such as checking all references, dll versions, uninstalling-reinstalling Glass.Mapper and debugging, this error didn’t disappear. But strangely, it worked with the latest Prerelease beta version without any efforts. But, we were more inclined towards using stable version rather than Beta ones.

Resolution/Quick Checks:

Finally, Glass.Mapper’s latest stable version worked fine with SC9. Thanks to Mike Edwards for his prompt responses on the Slack channel.

So, if you are facing issues to get Glass.Mapper working with SC 9, here are the quick checks:

  1. Check Sitecore.Kernel and System.Web.Mvc versions to be correct, even before installing Glass Mapper. Reason being these assemblies are used to determine which version of the Glass.Mapper assemblies should be referenced.
  2. If you have multiple projects where Glass is being referenced or installed, check for their versions, or better uninstall and re-install (especially if you have this upgraded Sitecore). If you have installed through Nuget, you can manage the Glass versions for all the projects by simply selecting “Manage NuGet Packages for Solution”, by right clicking on the solution.
  3. Once the Glass has been installed, make sure that Glass.Mapper.Sc should be referenced from lib/111 (packages/Glass.Mapper.Sc.Core/lib/111) and not lib/82 or any other. When I installed I noticed that, it by default refers this dll from lib/82, so I had to update it.  You may check for other two Glass dlls too. “Glass.Mapper.Sc.Mvc” should be referenced from lib/Mvc52 and Glass.Mapper from lib/net45.
  4. If you are still getting the same error, delete the entire bin and obj folders from all of your projects in the solution, rebuild and deploy.
  5. It should be working by now, but for me I had to bounce the IIS to get it working after performing all the above steps.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>