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)
This might happen when context hasn't been loaded properly.
Make sure you deployed all the config's that comes with Glass eg:
Also make sure you copied across all the .dll's that comes with Glass Installation.