Skip to content
February 8, 2015 / kiranpatils

The given key was not present in the dictionary error with Glass Mapper


We developed one module, and while testing it on anther machine. We faced following error:

Exception: System.Collections.Generic.KeyNotFoundException
Message: The given key was not present in the dictionary.
Source: mscorlib
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Glass.Mapper.AbstractService..ctor(String contextName)
   at Glass.Mapper.Sc.SitecoreService..ctor(String databaseName, String contextName)

Yes, as per the error message. It is something to do with Glass for sure! And yes, we used Glass to fetch data. Sorry you don’t know about Glass? No worries, Will strongly recommend you to start using Glass [The easiest way to map Sitecore data to code.] for all your Sitecore projects — WebForms/MVC. Glass Website :


We did a quick search, and found this thread : But, still no luck 😦

Then we started our investigation, and found that we missed to deploy : Website\App_Config\Include\Glass.Mapper.Sc.CastleWindsor.config file. Thanks to Nilesh Thakkar!

After doing that, all green!

Happy Glass Mapping! 🙂



Leave a Comment
  1. Jan Bühler / Nov 10 2015 4:45 pm

    Thanks, that helped me 🙂

    • kiranpatils / Nov 10 2015 11:36 pm

      Glad to know!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: