Copied to clipboard

Flag this post as spam?

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


  • Leon Degeling 3 posts 23 karma points
    Jan 19, 2013 @ 16:27
    Leon Degeling
    0

    putting a macro in a dictionary item seems broken since 4.10

    I recently upgraded one of my sites from 3.0.2 up to 4.10. This went great up to 4.9 but in 4.10 umbraco starts raising exceptions, i started cleaning out my templates until I found the cause. It's a macro that i call inside a header dictionary item.(i used to do that all the time before i understood masterpages :-)) I found that the macro is not the problem; it just runs fine when called from a template.

    I am now wondering if this is a bug introduced in v4.10 or is this caused by a mistake i made during the upgrade. Can someone test this on their install please and tell me what happens,

    (i run on windows server 2008, sql, just plain umbraco no extentions, packages etc)

    Thanks for your help.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 20, 2013 @ 00:16
    Jan Skovgaard
    0

    Hi Leon

    Do you still have the issue? Or did you manage to solve the issue and now you're just being curious? :)

    What kind of error description did you get if any? And could you show a screendump that displays how you used to do it?

    It's important to keep in mind that Umbraco was rewritten making use of native .NET stuff like asp.net masterpages etc so other things have been affected as well for sure and it might be related to this.

    /Jan

  • Leon Degeling 3 posts 23 karma points
    Jan 20, 2013 @ 21:20
    Leon Degeling
    0

    Since the upgrade to 4.10 caused errors I went back to 4.9, and that is the version i am currently running on. I will be happy to try to fix this problem myself, but first i want to make sure this is not a problem in my installation. You can see the error below.

     

    Leon

     

    Server Error in '/' Application.


    The given key was not present in the dictionary.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [KeyNotFoundException: The given key was not present in the dictionary.]
       System.Collections.Generic.Dictionary`2.get_Item(TKey key) +12686831
       Umbraco.Core.Macros.MacroTagParser.ParseMacros(String text, Action`1 textFoundCallback, Action`2 macroFoundCallback) +745
       umbraco.presentation.templateControls.Item.OnInit(EventArgs e) +329
       System.Web.UI.Control.InitRecursive(Control namingContainer) +133
       System.Web.UI.Control.InitRecursive(Control namingContainer) +421
       System.Web.UI.Control.InitRecursive(Control namingContainer) +421
       System.Web.UI.Control.InitRecursive(Control namingContainer) +421
       System.Web.UI.Control.InitRecursive(Control namingContainer) +421
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1970
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

    Request Details

    Session Id: bhcposo1xpm5t2mlhpogaxf2 Request Type: GET
    Time of Request: 20-1-2013 21:10:39 Status Code: 500
    Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8)

    Trace Information

    CategoryMessageFrom First(s)From Last(s)
    aspx.page Begin PreInit    
    aspx.page End PreInit 0,951684716386734 0,951685
    aspx.page Begin Init 0,951742312798861 0,000058
    item Start parsing '#head1a' 1,02014893152256 0,068407
    item Done parsing '#head1a' 1,02056746545069 0,000419
    item Start parsing 'titel' 1,0262865758549 0,005719
    item Done parsing 'titel' 1,0263497185882 0,000063
    item Start parsing '#head1b' 1,02643461996607 0,000085
    item Done parsing '#head1b' 1,02649093645793 0,000056
    renderMacro Rendering started (macro: Hoofdmenu, type: 1, cacheRate: 0) 1,10043449026749 0,073944
    umbracoMacro Xslt node adding search start (source,'1044') 1,12724540679279 0,026811
    umbracoMacro Before adding extensions 1,16004763009963 0,032802
    umbracoXsltExtension Extension added: urn:Exslt.ExsltCommon, ExsltCommon 1,20099483936147 0,040947
    umbracoXsltExtension Extension added: urn:Exslt.ExsltDatesAndTimes, ExsltDatesAndTimes 1,20103622345019 0,000041
    umbracoXsltExtension Extension added: urn:Exslt.ExsltMath, ExsltMath 1,20106352841594 0,000027
    umbracoXsltExtension Extension added: urn:Exslt.ExsltRegularExpressions, ExsltRegularExpressions 1,20108955346142 0,000026
    umbracoXsltExtension Extension added: urn:Exslt.ExsltStrings, ExsltStrings 1,20111472522672 0,000025
    umbracoXsltExtension Extension added: urn:Exslt.ExsltSets, ExsltSets 1,20114672323345 0,000032
    umbracoMacro After adding extensions 1,20116762859786 0,000021
    umbracoMacro Before performing transformation 1,2070659278398 0,005898
    umbracoMacro After performing transformation 1,27667225849611 0,069606
    item Start parsing '#header' 1,27677977179875 0,000108
    item Done parsing '#header' 1,27683352845007 0,000054
    Unhandled Execution Error
    The given key was not present in the dictionary.
      at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
      at Umbraco.Core.Macros.MacroTagParser.ParseMacros(String text, Action`1 textFoundCallback, Action`2 macroFoundCallback)
      at umbraco.presentation.templateControls.Item.OnInit(EventArgs e)
      at System.Web.UI.Control.InitRecursive(Control namingContainer)
      at System.Web.UI.Control.InitRecursive(Control namingContainer)
      at System.Web.UI.Control.InitRecursive(Control namingContainer)
      at System.Web.UI.Control.InitRecursive(Control namingContainer)
      at System.Web.UI.Control.InitRecursive(Control namingContainer)
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  • Leon Degeling 3 posts 23 karma points
    Jan 22, 2013 @ 00:49
    Leon Degeling
    0

    Today I downloaded the v4.10.1 source, found the problem and made a fix.

    The problem was in MacroTagParser.cs (part of the core), the troublesome line is

    var macroAlias = attributes["macroalias"] ?? attributes["alias"];

     

    My macro tag only had an alias attribute, the programmer probably assumed that a non existing dictionary-item would return null, but that's not the case.

    I replaced the line above with the following which works for me.

    var macroAlias = "";
    if (attributes.Keys.IndexOf("macroalias") == -1)
        macroAlias = attributes["alias"];
    else
       
    macroAlias = attributes["macroalias"];

    I built the core.dll, replaced it on the server and to my delight it works fine. 
    I have no idea if this was fixed in a later release, maybe someone more experienced can check this and maybe put a fix like this in some future release.

    If someone reads this who experiences the same problem, the quick fix is to change you macro tag and use the macroalias attribute instead of the macro attribute.

    Leon

Please Sign in or register to post replies

Write your reply to:

Draft