I have the following wrapper helper class that I use for MarkDown.
public static class MarkdownHelper
{
static Markdown _MarkdownTransformer;
static MarkdownHelper()
{
_MarkdownTransformer = new Markdown( new MarkdownOptions { AutoNewLines = true, AutoHyperlink = true, StrictBoldItalic = true } );
}
public static IHtmlString Markdown(this HtmlHelper helper, string text)
{
string html = _MarkdownTransformer.Transform(text);
return new MvcHtmlString(html);
}
}
This only seems to be able to generate (once in a few times) an Exception on first hit:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at MarkdownSharp.Markdown.FormParagraphs(String text)
at MarkdownSharp.Markdown.RunBlockGamut(String text)
at MarkdownSharp.Markdown.Transform(String text)
at AppExtensions.MarkdownHelper.Markdown(HtmlHelper helper, String text)
[...]
It seems to me like a concurrency problem. I'm using the latest stable version of MarkDownSharp.
Do I need to a different pattern for the wrapper class?