Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The same key was already used for another template!' #147

Open
Valter479 opened this issue Mar 1, 2016 · 2 comments
Open

"The same key was already used for another template!' #147

Valter479 opened this issue Mar 1, 2016 · 2 comments

Comments

@Valter479
Copy link

I keep getting the following error:


System.InvalidOperationException

The same key was already used for another template!


System.InvalidOperationException: The same key was already used for another template!
   at RazorEngine.Templating.DelegateTemplateManager.<>c__DisplayClass1.<AddDynamic>b__0(ITemplateKey k, ITemplateSource oldSource)
   at System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, TValue addValue, Func`3 updateValueFactory)
   at RazorEngine.Templating.DelegateTemplateManager.AddDynamic(ITemplateKey key, ITemplateSource source)
   at RazorEngine.Templating.TemplateService.GetKeyAndAdd(String template, String name)
   at RazorEngine.Templating.TemplateService.GetTemplate(String razorTemplate, Object model, String cacheName)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse(String razorTemplate, Object model, String cacheName)
   at Postal.FileSystemRazorView.Render(ViewContext viewContext, TextWriter writer)
   at Postal.EmailViewRenderer.RenderView(IView view, ViewDataDictionary viewData, ControllerContext controllerContext, ImageEmbedder imageEmbedder)
   at Postal.EmailViewRenderer.Render(Email email, String viewName)
   at Postal.EmailService.CreateMailMessage(Email email)
   at Postal.EmailService.Send(Email email)

I am not sure why?

I am using hangfire to send email as background job.

@dmbritos
Copy link

dmbritos commented May 9, 2016

I have the same issue, also using hangfire to send emails as background job. It seems to occur after editing the template while running the application. This post seems to be related (see the first item under "Explanation" in the matthid's answer):

http://stackoverflow.com/questions/29803561/razorengine-error-trying-to-send-email

@jacksonmarina12
Copy link

Looks like you're encountering a key conflict issue. Have you tried checking door cable if the key is being reused elsewhere in your templates? That might help resolve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants