11

Just updated a simple instance of Sitecore 8.1 to 8.2, the actual solution contains a simple demo, some templates, items, nothing too complex. All went fine as I followed all the steps from the upgrade document but now when I try to get into Sitecore I get the following:

Attempt by method 'Glass.Mapper.Sc.Utilities.get_IsPageEditor()' to access method 'Sitecore.Context+PageMode.get_IsPageEditor()' failed.

Is there a fix for this error somewhere? from the details below it seems to be from Glass and not Sitecore or my code.

enter image description here

EDIT:

After I removed all Glass packages from packages folder, removed entries from packages.config, removed all configs and then reinstalled a clean version of Glass.Mapper.SC and Glass.Mapper.Sc.MVC-5 via nuget on my solution now I get:

Could not resolve type name: Glass.Mapper.Sc.Pipelines.Response.GetModelFromView, Glass.Mapper.Sc.Mvc (method: Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)).

enter image description here

I checked with dotPeek and indeed there isn't such method, but not sure why then there is this entry in Glass config:

<mvc.getModel>
        <processor patch:before="*[@type='Sitecore.Mvc.Pipelines.Response.GetModel.GetFromItem, Sitecore.Mvc']"  type="Glass.Mapper.Sc.Pipelines.Response.GetModel, Glass.Mapper.Sc.Mvc"/>
        <processor patch:before="*[@type='Sitecore.Mvc.Pipelines.Response.GetModel.GetFromItem, Sitecore.Mvc']"  type="Glass.Mapper.Sc.Pipelines.Response.GetModelFromView, Glass.Mapper.Sc.Mvc"/>
</mvc.getModel>

Then if I remove this again from config I get another error:

Method not found: 'Glass.Mapper.Sc.SitecoreContext Glass.Mapper.Sc.SitecoreContext.GetFromHttpContext(System.String)'.

Did anyone managed to have Glass working on a Sitecore 8.2 solution? I am not sure what else can I do to make it work fine.

My package entries:

 <package id="Glass.Mapper.Sc" version="4.2.1.188" targetFramework="net452" />
  <package id="Glass.Mapper.Sc.Core" version="4.2.1.188" targetFramework="net452" />
  <package id="Glass.Mapper.Sc.Mvc-5" version="3.3.1.48" targetFramework="net452" />

Glass.Mapper.Sc.Mvc.config:

<sitecore>
  <settings></settings>
  <pipelines>
    <mvc.getModel>
      <processor type="Glass.Mapper.Sc.Pipelines.Response.GetModel, Glass.Mapper.Sc.Mvc" />
    </mvc.getModel>
  </pipelines>
</sitecore>

Glass.Mapper.Sc.config:

<sitecore>
  <settings></settings>
  <pipelines>
    <mvc.getModel>
      <processor patch:before="*[@type='Sitecore.Mvc.Pipelines.Response.GetModel.GetFromItem, Sitecore.Mvc']"  type="Glass.Mapper.Sc.Pipelines.Response.GetModel, Glass.Mapper.Sc.Mvc" />
      <processor patch:before="*[@type='Sitecore.Mvc.Pipelines.Response.GetModel.GetFromItem, Sitecore.Mvc']"  type="Glass.Mapper.Sc.Pipelines.Response.GetModelFromView, Glass.Mapper.Sc.Mvc" />
    </mvc.getModel>
    <getChromeData>
      <processor type="Glass.Mapper.Sc.Pipelines.GetChromeData.EditFrameBuilder, Glass.Mapper.Sc" patch:before="processor[1]" />
    </getChromeData>
  </pipelines>
  <events>
    <event name="publish:end">
      <handler type="Glass.Mapper.Sc.Events.PublishEnd.GlassCacheClear, Glass.Mapper.Sc" method="ClearCache" />
    </event>
    <event name="publish:end:remote">
      <handler type="Glass.Mapper.Sc.Events.PublishEnd.GlassCacheClear, Glass.Mapper.Sc" method="ClearCache" />
    </event>
  </events>
</sitecore>
8
  • Do you reference the correct Sitecore.Kernel.dll and have you updated Glass to its latest version?
    – Thomas D
    Sep 23, 2016 at 9:11
  • Yes, all references are good. Checked also the version and it's the latest 4.2.188 on all 3 dlls (Glass.Mapper.dll, Glass.Mapper.Sc.dll, Glass.Mapper.Sc.Mvc.dll) so not sure where the problem is.
    – Adrian C.
    Sep 23, 2016 at 9:23
  • Just to be sure: have you also checked the versions of the files in the website's bin folder?
    – Thomas D
    Sep 23, 2016 at 9:29
  • Yes, my first comment was for the bin versions in the website. So it's not from the dlls version.Sadly not from there.
    – Adrian C.
    Sep 23, 2016 at 9:38
  • Did you upgrade your Glass nuget references, or did you remove them and then re-add them?
    – jammykam
    Sep 23, 2016 at 12:54

3 Answers 3

5

I'm not sure if you're updating Glass Mapper at the same time, but I don't believe the Glass.Mapper.Sc.Mvc-5 package is required as of v4 (Apr 2015).

If you have a look at the v4 release notes they have simplified things down to one Nuget package: Glass.Mapper.Sc, which also includes the .Mvc dll that you require. If your Nuget package install doesn't add it automatically, you can find it at <your project>\packages\Glass.Mapper.Sc.Core.4.2.1.188\lib\Mvc5x\Glass.Mapper.Sc.Mvc.dll (where Mvc5x is the version of MVC you are using).

I have Glass Mapper working in 8.2, however when I installed the .Mvc-5 Nuget package you mentioned, I can replicate your Could not resolve type name: Glass.Mapper.Sc.Pipelines.Response.GetModelFromView issue.

If you can't get your project running without this .Mvc-5 Nuget package (you should be able to) let us know what appears to be missing / broken.

1
  • You are right. Mike Edwards helped me a few days with this problem but I forgot to update this. He said exactly the same thing, I was using also the MVC package and I shouldn't have so I removed it and works perfectly now. Thanks a lot.
    – Adrian C.
    Sep 27, 2016 at 7:50
8

You need to use latest version of glass mapper: https://www.nuget.org/packages/Glass.Mapper.Sc/4.2.1.188 with Sitecore 8.2

In the new version you have:

 namespace Glass.Mapper.Sc
 {
   public class Utilities : Glass.Mapper.Utilities
   {
       public static bool IsPageEditor
       {
           get
           {
              return Sitecore.Context.PageMode.IsExperienceEditor;
           }
       }
    }
}

Sitecore.Context.PageMode.IsExperienceEditor.IsPageEditor is private now, and it was changed with Sitecore.Context.PageMode.IsExperienceEditor.IsExperienceEditor.

3
  • I am using the latest version dlls from nuget but this doesn't help.
    – Adrian C.
    Sep 23, 2016 at 9:24
  • 1
    Your solutuon is not using the right version of Glass for 8.2 if it is trying to call IsPageEditor. I would double check that your references are correct. Sep 23, 2016 at 10:46
  • 1
    @PeteNavarra I just did, and the versions were ok, but to be sure I reinstalled it from nuget and now I am getting other errors. (see latest edit on the question).
    – Adrian C.
    Sep 23, 2016 at 15:20
1

The above answers didn't help me here. When I reflected out IsPageEditor for 4.2.188 it still used IsPageEditor not IsExperienceEditor. Looking at the source code it seems to depend on how the assembly is built:

public class Utilities : Mapper.Utilities
{

    public static bool IsPageEditor
    {
        get
        {
#if SC82
            return Sitecore.Context.PageMode.IsExperienceEditor;
#else
            return Sitecore.Context.PageMode.IsPageEditor;
#endif
        }
    }
    public static bool IsPageEditorEditing
    {
        get
        {
#if SC82
            return Sitecore.Context.PageMode.IsExperienceEditorEditing;
#else
            return Sitecore.Context.PageMode.IsPageEditorEditing;
#endif
        }
    }
...

enter image description here

It's unclear from the NuGet package what version each build is for. When I upgraded from 4.2.188 to 4.2.189 the assembly contained the correct version. Making my think that this is built for SC 8.2 as opposed to 8.1. Bascially it looks like a build mistake to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.