We're getting the error below when rendering a legacy VBScript component template (presentation) from a .NET page template.

The .NET code to do the rendering is straightforward:

var sb = new StringBuilder();

foreach (var presentation in page.ComponentPresentations)
    sb.AppendLine(engine.RenderComponentPresentation(presentation.Component.Id, presentation.ComponentTemplate.Id));

Further relevant context info:

  • Tridion 2013 SP1 (with LegacyPack)
  • Static component template
  • .NET 4.5
  • Windows Server 2008 R2 Standard

Anyone dealt with this issue before and/or knows how to solve? Any clue would be helpful. Thanks.

Here's the error:

Error: This key is already associated with an element of this collection UtilitiesPublish.RenderComponentPresentation ComponentPresentation.Render ComponentTemplate.Render UtilitiesPublish.RenderComponentPresentation ComponentPresentation.Render Component.Render at Tridion.ContentManager.Publishing.Legacy.Rendering.ComponentPresentationRenderer.Render(ResolvedItem resolvedItem, PublishInstruction instruction, PublicationTarget target, RenderedItem renderedItem, RenderContext context) at Tridion.ContentManager.Publishing.Rendering.RenderEngine.Render(ResolvedItem resolvedItem, PublishInstruction instruction, PublicationTarget target, RenderContext context) at Tridion.ContentManager.Publishing.Rendering.RenderEngine.Render(IdentifiableObject item, Template template, PublishInstruction instruction, PublicationTarget target, RenderContext context) at Tridion.ContentManager.Templating.Engine.RenderComponentPresentation(TcmUri componentUri, TcmUri componentTemplateUri)

2 Answers 2


Have you checked that it works when called from a VbScript Page Template? If it's really about the difference between a VbScript page template and a .NET one, you should look to see if the VbScript code in the component template directly addresses items that belong to the Page/PT. This was quite easy to do in VbScript and was quite a common technique. Obviously, that relies on you using a VbScript page template.

  • Thx @Dominic, this must be the cause. What exactly it is I still need to figure out. The error message is, however, not obvious to our situation, because that particular message only shows up in the scenario as described in the question. We do get (and expect) different errors when the CT is missing page context variables.
    – hoang
    Commented Feb 6, 2015 at 14:04

I think this could just be an error in your legacy Component Template.

According to the stack trace, the error has surfaced from inside RenderComponentPresentation, not from the code in your Page Template.

Googling the error message gives me lots of results regarding VB, VBA etc. and nothing related to .Net, which further points to the legacy template being the issue.

The error, "This key is already associated with an element of this collection", implies that you have some kind of dictionary in your code and you are trying to a key to it which is already present. I would advise to check your code and also the component being rendered for any duplicate data.

  • @ElenaS pointed out this comes up with circular references for Content Porting. For David's last point on checking the "component being rendered for any duplicate data," basically try a different Component that's not linked to other Components. Commented Feb 6, 2015 at 12:29
  • Thx @David. The error is indeed raised in the rendering of the legacy CT. It must be caused by what is discussed in Dominic's answer.
    – hoang
    Commented Feb 6, 2015 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.