Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jignesh 31 posts 51 karma points
    Jan 25, 2012 @ 19:11
    Jignesh
    0

    An item with the same key has already been added.

    Hello,

    Error occured

    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)
    at umbraco.macro.GetXsltExtensionsImpl()
    at umbraco.macro.b__4()
    at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem)
    at umbraco.macro.GetXsltExtensions()
    at umbraco.macro.AddMacroXsltExtensions()
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • Jignesh 31 posts 51 karma points
    Jan 25, 2012 @ 19:22
    Jignesh
    0

    I got error everywhere...

    Error parsing XSLT file: 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 25, 2012 @ 19:46
    Jan Skovgaard
    0

    Hi Jignesh

    Could you please ellaborate a bit more on these errors - then it will be much more easy for people to try and help you out and the replies you will get will be of much better quality.

    So a couple of things that would be good to know in order to help you out

    • What version of Umbraco are you using?
    • Is this happening on a fresh install?
    • Have you made an upgrade from an older version to a newer version?
    • Have you made a custom XSLT extension or other custom code?
    • When did this start to happen?
    • Have you installed some package that could be the cause?

    Looking forward to hear more from you :)

    /Jan

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 25, 2012 @ 21:56
    Jeroen Breuer
    0

    Did you upgrade from an older Umbraco version? If all your xslt files give an error it could be this: http://our.umbraco.org/forum/ourumb-dev-forum/bugs/18381-All-xslt-files-broken-after-upgrading-to-47

    Jeroen

  • Justin Spradlin 139 posts 347 karma points
    Jan 25, 2012 @ 22:31
    Justin Spradlin
    0

    I had this exact same problem on Sunday. I have a site that is working in production, but I pulled the latest code from my HG repository to work on it locally. I backed up the DB and restored it locally. So, it should be an identical version to what is running. Every macro that calls a XSLT file gives this duplicate key exception. I even tried to pull down the code on a different laptop with the same results. 

    I have tried to update to 4.7.1.1 (was on 4.7.1) and that did not help. I am using SQL Express as the back end. I have tried to touch the web.config to flush the cache and that did not help either. I can try to reproduce later this evening and give more details.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 25, 2012 @ 22:35
    Jan Skovgaard
    0

    Hi Justin

    Do you know if there has been made any custom xslt extensions or some user controls that could be causing this?

    If you see the xslt renderings errors it can be caused by a reference missing in the xsltExtensions.config file. It can also be caused by some of the dll files mentioned in the post Jeroen is linking to above.

    /Jan

  • Justin Spradlin 139 posts 347 karma points
    Jan 25, 2012 @ 22:39
    Justin Spradlin
    0

    I don't have any of the legacy dlls, this site started with 4.7.0 then upgraded to 4.7.1. I also checked and I don't have any missing references in the xslt extensions config file. I even tried to comment out all of the extensions and that did not help either. 

  • Justin Spradlin 139 posts 347 karma points
    Jan 26, 2012 @ 05:39
    Justin Spradlin
    0

    I can reproduce this by either loading a page referencing ANY XSLT macro, or by trying to save the XSLT in the backoffice. I am stuck on this one. I have tried everything I can think of. I guess next I'll have to get the source and try to debug umbraco core to see if it gives me any more information. 

    Here is the trace info in case it helps anyone.

     

     
     
    CategoryMessageFrom First(s)From Last(s)
    aspx.page Begin PreInit    
    umbracoInit handling request 2.95654737682387E-05 0.000030
    request handler current url '' 0.000140025368819019 0.000110
    umbracoRequestHandler xpath: '/root/*' 0.000176982211029318 0.000037
    umbracoRequestHandler xpath: '/root/* [@urlName = ""] | /root/*' 0.000192996842653781 0.000016
    umbracoRequestHandler xpath: '/root/* [@urlName = ""] | /root/*' 0.000213117790079387 0.000020
    umbracoRequestHandler Just before xPath query (False, '/root/* [@urlName = ""] | /root/*') 0.000228721790123736 0.000016
    umbracoRequestHandler pageXPathQueryStart: '/root' 0.000242272632267512 0.000014
    umbracoRequestHandler After xPath query 0.000277176316577238 0.000035
    umbracoRequestHandler Access checking started 0.00030797368508582 0.000031
    umbracoRequestHandler Page not protected 0.000328505264091541 0.000021
    umbracoRequestHandler Access checking ended 0.000342056106235317 0.000014
    umbracoInit Done handling request 0.00035807073785978 0.000016
    umbracoPage Element loaded: siteName 0.000543676212071501 0.000186
    umbracoPage Element loaded: bodyText 0.000583096843762486 0.000039
    umbracoPage Pagedata loaded for Home (ID: 1099) 0.000600343370127292 0.000017
    umbracoPage Looking up skin information 0.00062990884389553 0.000030
    default.aspx Culture changed to en-US 0.000794161475941301 0.000164
    aspx.page End PreInit 0.000935418739500664 0.000141
    aspx.page Begin Init 0.000980177581733136 0.000045
    item Start parsing 'pageName' 0.0010134387397224 0.000033
    item Done parsing 'pageName' 0.00105984010827534 0.000046
    item.recursive Item loaded from 1099 0.00112554116109364 0.000066
    item Start parsing 'siteName' 0.00114443021377891 0.000019
    item Done parsing 'siteName' 0.00116947874016589 0.000025
    item.recursive Item loaded from 1099 0.0012039717928955 0.000034
    item Start parsing 'siteName' 0.00121957579293985 0.000016
    item Done parsing 'siteName' 0.00124626684564728 0.000027
    renderMacro Rendering started (macro: Top Navigation, type: 1, cacheRate: 0) 0.00185728663685755 0.000611
    umbracoMacro Before adding extensions 0.00196733590032822 0.000110
    umbracoMacro InnerException An item with the same key has already been added.
    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)
      at umbraco.macro.GetXsltExtensionsImpl()
      at umbraco.macro.<GetXsltExtensions>b__4()
      at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem)
      at umbraco.macro.GetXsltExtensions()
      at umbraco.macro.AddMacroXsltExtensions()
      at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters)
      at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)
    0.103393746820172 0.101426
    renderMacro Rendering started (macro: Slider Images, type: 1, cacheRate: 0) 0.104344769559717 0.000951
    umbracoMacro Before adding extensions 0.104450712507386 0.000106
    umbracoMacro InnerException An item with the same key has already been added.
    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)
      at umbraco.macro.GetXsltExtensionsImpl()
      at umbraco.macro.<GetXsltExtensions>b__4()
      at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem)
      at umbraco.macro.GetXsltExtensions()
      at umbraco.macro.AddMacroXsltExtensions()
      at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters)
      at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)
    0.210304963755604 0.105854
    aspx.page End Init 0.210637164703916 0.000332
    aspx.page Begin InitComplete 0.210656053756601 0.000019
    aspx.page End InitComplete 0.210671247125066 0.000015
    aspx.page Begin PreLoad 0.21068520859879 0.000014
    aspx.page End PreLoad 0.210699580704094 0.000014
    aspx.page Begin Load 0.210713131546237 0.000014
    aspx.page End Load 0.21075830102005 0.000045
    aspx.page Begin LoadComplete 0.210773494388514 0.000015
    aspx.page End LoadComplete 0.210787455862238 0.000014
    aspx.page Begin PreRender 0.210803470493862 0.000016
    aspx.page End PreRender 0.210833857230791 0.000030
    aspx.page Begin PreRenderComplete 0.210849461230835 0.000016
    aspx.page End PreRenderComplete 0.210863422704559 0.000014
    aspx.page Begin SaveState 0.211410383969272 0.000547
    aspx.page End SaveState 0.211501544180057 0.000091
    aspx.page Begin SaveStateComplete 0.211518790706422 0.000017
    aspx.page End SaveStateComplete 0.211533162811726 0.000014
    aspx.page Begin Render 0.21154671365387 0.000014
    aspx.page End Render 0.212274352813832 0.000728
  • Justin Spradlin 139 posts 347 karma points
    Jan 26, 2012 @ 06:21
    Justin Spradlin
    3

    I solved it for my instance. The problem was that I have created a Web Application project to maintain my project in Visual Studio. I also use the XSLTSearch package. When I created my web app project, I copied teh XsltSearch.cs class into the App_Code folder of my web application. Because this file had the build action set to compile it was compiled into Mysite.umbraco.dll (my web application's dll) AND a dynamically compiled by asp.net due to the fact that it was in the ASP.NET App_Code folder. 

     

    So, when umbraco runs the following bit of code in umbraco.presentation.macro.GetXsltExtensionsImpl(), the system returns two instances of XSLTSearch. Since this class is decorated with the XsltExtension attribute, it will find this class in both assemblies and try to add both items to the collection of XsltExtensions. 

        // zb-00042 #29949 : do not hide errors, refactor
                foreach (Type xsltType in BusinessLogic.Utils.TypeFinder.FindClassesMarkedWithAttribute(typeof(XsltExtensionAttribute)))
                {
                    object[] tpAttributes = xsltType.GetCustomAttributes(typeof(XsltExtensionAttribute), true);
                    foreach (XsltExtensionAttribute tpAttribute in tpAttributes)
                    {
                        string ns = !string.IsNullOrEmpty(tpAttribute.Namespace) ? tpAttribute.Namespace : xsltType.FullName;
                        extensions.Add(ns, Activator.CreateInstance(xsltType));
                    }
                }

    To fix the problem, I was able to just move that XsltSearch.cs out of the App_Code folder, thus there was only one version (the one that got compiled into my web app's dll. 

     

    If you are still having this problem, check for any classes decorated with the [XsltExtension] attribute instead of in the /config/xsltExtensions.config file. 


    Thanks,

     

    Justin

  • Jignesh 31 posts 51 karma points
    Jan 27, 2012 @ 07:33
    Jignesh
    0

    Hi Jan Skovgaard

    What version of Umbraco are you using?

    -- V4.7.1

    Is this happening on a fresh install?

    -- No, I am already uploaded site on server. its working fine, but on thrusday I added some functionality for this installed pagkages uComponent, PDCalendar...

    and then uninstall PDCalendar as no use of this so..

    its working fine on local but when upload it on live all xslt files gives error..

    Have you made an upgrade from an older version to a newer version?

    -- No

    Have you made a custom XSLT extension or other custom code?

    -- No

    When did this start to happen?

    -- after installing pagkages uComponent, PDCalendar... i think so..

    Have you installed some package that could be the cause?

    -- uComponent, PDCalendar... but remove PDCalendar..

    also delete dll for pdcalendar from bin..

     

    Thanks..

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 28, 2012 @ 01:13
    Jan Skovgaard
    0

    Hi Jignesh

    Sorry for my late reply on this one.

    Have you checked the to see if the uComponents XSLT extensions (if you installed that part of the package) have been referenced in the xsltConfig.config file? In the /config folder.

    /Jan

  • Greg Berlin 818 posts 634 karma points
    Mar 25, 2012 @ 23:36
    Greg Berlin
    1

    Brilliant, thanks so much... deleting XsltSearch.cs from App_Code solved this one for me. :)

  • Jonas Eriksson 930 posts 1825 karma points
    May 08, 2013 @ 14:52
    Jonas Eriksson
    0

    Thanks Justin, it helped me to solve same problem here (custom .cs with xsltattribute) after moving to another server.

Please Sign in or register to post replies

Write your reply to:

Draft