mustache-sharp icon indicating copy to clipboard operation
mustache-sharp copied to clipboard

"Item with the same key already added" exception in PropertyDictionary

Open geordiemhall opened this issue 9 years ago • 1 comments

Occasionally when rendering a relatively simple template I get the following error:

[ArgumentException: An item with the same key has already been added.]
   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +14648955
   Mustache.PropertyDictionary.getCacheType(Object instance) +960
   Mustache.PropertyDictionary..ctor(Object instance) +41
   Mustache.Scope.tryFindFirst(SearchResults results) +74
   Mustache.Scope.tryFind(String name) +175
   Mustache.KeyGenerator.Mustache.IGenerator.GetText(Scope scope, TextWriter writer, Scope context) +80
   Mustache.CompoundGenerator.Mustache.IGenerator.GetText(Scope keyScope, TextWriter writer, Scope contextScope) +477
   Mustache.CompoundGenerator.Mustache.IGenerator.GetText(Scope keyScope, TextWriter writer, Scope contextScope) +477
   Mustache.Generator.render(IFormatProvider provider, Object source) +769

When you refresh the page it's fine, and Mustache should be given the same data every time.

There could potentially be something weird in the data that it's given since I haven't investigated fully, but just thought I'd see if there's any obvious reason why this might happen?

I've tried looking through the getCacheType() method myself but I'm not super familiar with the internals of how MustacheSharp works so nothing really stood out at me.

geordiemhall avatar Nov 19 '15 03:11 geordiemhall

It's 2020, Any solution to this? I am getting the same issue randomly.

heysaad avatar Aug 04 '20 22:08 heysaad