jehugaleahsa / mustache-sharp

An extension of the mustache text template engine for .NET.
The Unlicense
306 stars 78 forks source link

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

Open geordiemhall opened 8 years ago

geordiemhall commented 8 years ago

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.

heysaad commented 4 years ago

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