Olav Aukan Getting information off the Internet is like taking a drink from a fire hydrant…

4Mar/10

Error when editing People Search Core Results Web Part XSL

Today I was tasked with removing the "Add to My Colleagues" link from the people search results. I figured this would be easy, just edit the XSL of the People Search Core Results Web Part. I simply commented out the part that added the link:

<xsl:template name="DisplayAddToMyColleaguesLink">
   	<xsl:param name="url"/>

<!-- Remove "Add to My Colleagues" link

    <a href="{$url}">
		<xsl:value-of select="$AddToMyColleaguesText"/>
    </a><br/>

-->

</xsl:template>

I then went on to save the changes but much to my surprise (and horror) the Web Part displayed the following error:

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)...

Of course I assumed I had somehow made the XSL invalid with my editing, so I pasted in the original and clicked Save again, but the error would not go away. Unable to resolve the issue I ended up discarding the checkout and starting all over again. This time I did a simple Select All -> Copy -> Delete -> Paste, but even without making any modifications to the XSL I got the same error.

After some googling I found out that this is a known bug, and the workaround is to simply check in and publish the page. I did so, the error went away, and the "Add to My Colleagues" link was now gone from the search results.