0

We're trying to configure Glass Mapper for our Sitecore 6.6 instance but came across this error when testing it out.

[KeyNotFoundException: The given key was not present in the dictionary.] System.Collections.Generic.Dictionary`2.get_Item(TKey key) +13763207 Glass.Mapper.AbstractService..ctor(String contextName) +99 Glass.Mapper.Sc.SitecoreService..ctor(Database database, String contextName) +55 Glass.Mapper.Sc.SitecoreContext..ctor() +98 [Sublayout].Page_Load(Object sender, EventArgs e) in [Sublayout].ascx.cs:18 System.Web.UI.Control.OnLoad(EventArgs e) +109 System.Web.UI.Control.LoadRecursive() +68 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4498

and the code calling this is

protected void Page_Load(object sender, EventArgs e)
    {
        var context = new SitecoreContext();
        Model = context.GetCurrentItem<Article>();
    }

Version 3.3.1.53 is installed (as we had issues with our version of Sitecore on 4.x versions)

Harshil Shah
  • 203
  • 1
  • 16
Bauza23
  • 191
  • 3
  • 18

1 Answers1

0

This might happen when context hasn't been loaded properly.

Make sure you deployed all the config's that comes with Glass eg:

Website\App_Config\Include\Glass.Mapper.Sc.CastleWindsor.config

Also make sure you copied across all the .dll's that comes with Glass Installation.

Dheeraj Palagiri
  • 1,829
  • 3
  • 23
  • 46
  • Yes, that file does appear to be missing. Is there any reason why this would fail to come across with the nuget install? – Bauza23 Dec 22 '16 at 11:08
  • Castle Windsor has been removed from GlassMapper v4, as you said you are on Version 3.3.1.53 it should get it from nuget install. Don't know what happened there. – Dheeraj Palagiri Dec 22 '16 at 11:49
  • The issue was due to the Glass.Mapper.Sc package being installed instead of Glass.Mapper.Sc.CastleWindsor which has since been deprecated but is the only version Glass with an out of the box DI setup that works for Sitecore 6.6. – Bauza23 Dec 28 '16 at 11:11
  • FWIW; the package can be found here: https://www.nuget.org/packages/Glass.Mapper.Sc.CastleWindsor – Bauza23 Dec 28 '16 at 11:12