Copied to clipboard

Flag this post as spam?

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


  • Sean Hill 2 posts 23 karma points
    Mar 01, 2011 @ 01:07
    Sean Hill
    1

    Razor Error

    I realize that there is a new version (4.7) of Umbraco coming out, but I need to publish a macro for a running site tonight.  This is the first time that I have used Razor, so I'm sure I'm doing something wrong, but I have the following error message:

    An unknown error occured while rendering the following code:

    System.NullReferenceException: Object reference not set to an instance of an object. at RazorEngine.Dynamic.baeffbebc.Execute() at RazorEngine.Templating.TemplateService.Parse[T](String template, T model, String name) at umbraco.MacroEngines.RazorEngine.GetResult(String cacheIdentifier, String template, INode currentPage, String& result)

    My macro looks like this:

    @using System
    @using uComponents.Core
    @using uComponents.Core.uQueryExtensions
    @using System.Linq
    @using umbraco.NodeFactory
    @helper NoPictures()
    {
     <li>Pictures coming soon!</li>
    }

    @helper Pictures(String crop)
    {
     <li><rel="photos" href="@crop" title="test">
            <img src="@crop" class="shadow hovershadow"></a></li>
    }
    @{
       var Node.GetCurrent();
       var pictures n.GetProperty("pictures").Value;
       if(pictures.Length <= 0)
       {
         NoPictures();
       }
       else
       {
         var pictureNodes pictures.Split(',');
         
         foreach (var pictureNode in pictureNodes)
         {
          var node new Node(Convert.ToInt32(pictureNode));
          var photoId node.GetProperty("picture").Value;
          var photo uComponents.Core.uQuery.GetMedia(Convert.ToInt32(photoId));
          var crop MediaExtensions.GetImageCropperUrl(photo"umbracoFile""wide");
          Pictures(crop);
         }
       }

    }


    Thank you so much for the help.

  • Sean Hill 2 posts 23 karma points
    Mar 01, 2011 @ 06:24
    Sean Hill
    0

    The problem has been solved.  Apparently a previous error was cached by Umbraco and the cache was not being invalidated despite making changes to the script.  I'm pretty sure this is a bug in the way Umbraco caches Razor macros.  I solved the problem by recycling the Application Pool in IIS.

     

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft