I'm new to Razor templates in Umbraco (and in general), but I prefer using it over XSLT files. However, I have run into a problem that I don't know how to solve. I am getting the following 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><a rel="photos" href="@crop" title="test">
<img src="@crop" class="shadow hovershadow"></a></li>
}
@{
var n = 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);
}
}
}
I really appreciate any help that anyone can offer... even if it is giving me an idea how to debug this within Umbraco. Thanks!
Edit: The version of Umbraco 4.6.1