Copied to clipboard

Flag this post as spam?

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


  • wayne nixon 12 posts 32 karma points
    Feb 02, 2014 @ 15:44
    wayne nixon
    0

    Error loading MacroEngine script (file: LawyerProfileView.cshtml)

    Working on site i been handed and suddnely a couple of macros have started playing up. Macro was working fine now suddenly this error showed up can anyone help here is the code.

     

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
             
    @functions{

                 
    public void SetPageTitle(string title)
                 
    {
                     
    var page = HttpContext.Current.Handler as Page;
                     
    if (page != null){
                          page
    .Title = title;
                     
    }
                 
    }

                 
    public DynamicNode Homepage
                 
    {
                     
    get {
                         
    var homepage = Model;
                         
    while(homepage.NodeTypeAlias != "Homepage"){
                              homepage
    = homepage.Parent;
                         
    }

                         
    return homepage;
                     
    }
                 
    }

                 
    public HtmlString GetSocialMediaLink(string network, string url, string name)
                 
    {
                     
    var socialMediaRepo = Library.NodeById(-1).DescendantsOrSelf("SocialMediaNetworkRepository").First();
                     
    var socialNetworks = new List<DynamicNode>();
                     
    if (socialMediaRepo != null)
                     
    {
                         
    foreach (var child in socialMediaRepo.Children)
                         
    {
                             
    if(child.NodeTypeAlias.ToLower().Equals(network.ToLower())){
                                 
    var icon = child.HasValue("CssClass") ? String.Format("<i class=\"{0}\"></i>", child.CssClass) : String.Format("<img src=\"/imagegen.ashx?altimage=/images/assets/clear.gif&image={0}\" alt=\"{1}\"/>", child.Icon, child.Name);
                                 
    return new HtmlString(String.Format("<a target=\"_blank\" rel=\"no-follow\" href=\"{0}\" title=\"{3} on {1}\">{2}</a>", url, child.Name, icon, name) );
                             
    }
                              socialNetworks
    .Add(child);
                         
    }
                     
    }
                     
    return new HtmlString("");
                 
    }

             
    }
    @{
    if (String.IsNullOrEmpty(Request["name"])){
       
    return;
    }
    var profileId = Request["name"].Replace("-", " ").Replace("/", "");

    var lawyersRepository = Library.NodeById(1316);
    var isIntranet = Homepage.Name.IndexOf("intranet", StringComparison.OrdinalIgnoreCase) > -1;
    var nodes = isIntranet ? lawyersRepository.Children.Where("Name.ToLower() = \"" + profileId.ToLower() + "\"") : lawyersRepository.Children.Where("!ProfileIsPrivate && Name.ToLower() = \"" + profileId.ToLower() + "\"");
    if(!nodes.Any()){
       
    return;
    }
    var node = nodes.First();
    if (node == null || node.NodeTypeAlias != "LawyerRepositoryItem"){
       
    return;
    }

    if (node.ProfileIsPrivate && !isIntranet){
       
    return;
    }

    PageData["PageTitle"] = Model.Name + " - " + node.Name;

    SetPageTitle(Model.Name + " - " + node.Name);
    var hasContactInfo = (!String.IsNullOrEmpty(node.TelephoneNumber) || !String.IsNullOrEmpty(node.EmailAddress) || !String.IsNullOrEmpty(node.OfficeLocation));
    <div class="profile">
       
    <div class="row">
           
    <div class="span4 profile-content">
               
    <h1>@node.Name</h1>
                <h3>@node.JobTitle</
    h3>
               
    @Html.Raw(node.Biography.ToString())
           
    </div>
            <div class="span2">
                <div class="profile-picture">
                    @{
                        if (!node.HasValue("ProfilePictureSquare")){
                            <img src="/
    imagegen.ashx?altimage=/images/assets/clear.gif&image=@Library.MediaById(node.ProfilePicture).umbracoFile" alt="@node.Name" />
                        }
                        else{
                            <img src="
    /imagegen.ashx?altimage=/images/assets/clear.gif&image=@Library.MediaById(node.ProfilePictureSquare).umbracoFile" alt="@node.Name" />
                        }
                    }

                </div>
                <div class="
    profile-quote">
                    <!--Tesimonial-->
                    @RenderPage("
    ~/macroScripts/Widgets/Widget_RandomTestimonial.cshtml", @node.Id.ToString())
                </div>
            </div>
            @if (hasContactInfo)
            {
                <div class="
    contact-information">
                    <div class="
    pull-left contact-details">
                        <h4>@Dictionary.ContactInformationHeading</h4>
                        <dl class="">
                            @{
                if (node.HasValue("
    TelephoneNumber"))
                {
                                    <dd><strong>@Dictionary.Label_TelephoneShort:</strong>  @node.TelephoneNumber</dd>
                }
                if (node.HasValue("
    EmailAddress"))
                {
                                    <dd><strong>@Dictionary.Label_EmailShort:</strong> <a href="
    mailto:@node.EmailAddress?subject=@Dictionary.DefaultEmailSubjectLine">@node.EmailAddress</a></dd>
                }
                if (node.HasValue("
    OfficeLocation"))
                {
                    var officeNode = Library.NodeById(node.OfficeLocation);
                                    <dd><strong>@Dictionary.Label_Office:</strong> <a href="
    @officeNode.NiceUrl" title="@officeNode.Name">@officeNode.Name</a></dd>
                }
                            }
                        </dl>
                    </div>
                    <div class="
    pull-left contact-vcard">
                        <h4>
                            <a href="
    /vcard.ashx?contact=@node.Id" title="@Dictionary.DownloadVCard"><i class="t-icon-vcard"></i> <span>@Dictionary.DownloadVCard</span></a></h4>
                    </div>
                </div>
            }
            @{
                var hasSocialMediaUrls = node.HasValue("
    FacebookUrl") || node.HasValue("TwitterUrl") || node.HasValue("LinkedInUrl") || node.HasValue("YouTubeUrl") || node.HasValue("BlogUrl");
                if (hasSocialMediaUrls)
                {
                    <div class="
    profile-social-links social-links">

                        <ul class="
    unstyled">
                            <li><strong>@Dictionary.Connect</strong></li>
                            @if (node.HasValue("
    FacebookUrl"))
                            {
                                <li>@GetSocialMediaLink("
    facebook", node.FacebookUrl, node.Name)</li>
                            }
                            @if (node.HasValue("
    TwitterUrl"))
                            {
                                <li>@GetSocialMediaLink("
    twitter", node.TwitterUrl, node.Name)</li>
                            }
                            @if (node.HasValue("
    LinkedInUrl"))
                            {
                                <li>@GetSocialMediaLink("
    linkedin", node.LinkedInUrl, node.Name)</li>
                            }
                            @if (node.HasValue("
    YouTubeUrl"))
                            {
                                <li>@GetSocialMediaLink("
    youtube", node.YouTubeUrl, node.Name)</li>
                            }
                            @if (node.HasValue("
    BlogUrl"))
                            {
                                <li>@GetSocialMediaLink("
    blogger", node.BlogUrl, node.Name)</li>
                            }
                        </ul>

                    </div>
                }
            }
        </div>
        <div class="
    gold-bar">
            <a href="
    @Dictionary.SubmitTestimonialLink@Dictionary.SubmitTestimonialLinkParameters.Replace("{Name}", node.Name)">@Dictionary.SubmitTestimonialText</a>
        </div>
    </div>
    }

    i have tried loading from a backup file but the problem persists.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 02, 2014 @ 17:08
    Jeavon Leopold
    0

    Hi Wayne,

    Do you know what the exception is? If you are using v4.10+ you should be able to find the exceptions in the log4net file in /App_Data/Logs/

    Jeavon

  • wayne nixon 12 posts 32 karma points
    Feb 02, 2014 @ 17:25
    wayne nixon
    0

    WARN  umbraco.macro - [Thread 86] Error loading MacroEngine script (file: PrimaryNavigation.cshtml, Type: ''. Exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference

  • wayne nixon 12 posts 32 karma points
    Feb 02, 2014 @ 17:37
    wayne nixon
    0

    also got this error in debug mode:

    Error loading MacroEngine script (file: /Widgets/Widget_LawyerProfileWidgets.cshtml, Type: ''
    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Any'
      at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 02, 2014 @ 20:18
    Jeavon Leopold
    0

    Ok, have you added any new dlls to the bin folder, thinking possibly webgrease.dll or DotNetOAuth.dll?

  • wayne nixon 12 posts 32 karma points
    Feb 02, 2014 @ 20:32
    wayne nixon
    0

    I havnt but someone else may have i cant access the files till tuesday so i will check then if they are there shall i just delete them ?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 02, 2014 @ 21:11
    Jeavon Leopold
    0

    If you have WebGrease.dll upgrading to latest version should fix it, if it's DotNetOAuth.dll then only solution I know of is to delete it and seek alternative if it's required. There are some other dlls which can also cause problems.

    Obviously, first step is to see if any dlls have been added.

  • wayne nixon 12 posts 32 karma points
    Feb 03, 2014 @ 18:41
    wayne nixon
    0

    Hi Jeavon no dlls have been added but i even backed up the bin file from a previous backup that worked fine. but still no luck ?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 03, 2014 @ 19:02
    Jeavon Leopold
    0

    Hmm, that is strange. The .Any() extension method actually comes from System.Linq in System.Core.dll which is of course in the GAC. Does this issue occur in multiple environments, development and live etc?

  • wayne nixon 12 posts 32 karma points
    Feb 03, 2014 @ 19:07
    wayne nixon
    0

    we dont have the development site at the moment just the live site whats strange is that it was fine a few days ago

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 04, 2014 @ 21:32
    Jeavon Leopold
    0

    Hi Wayne,

    Could you try this

    if(nodes==null || !nodes.Any()){
        return;
    }
    

    Jeavon

  • wayne nixon 12 posts 32 karma points
    Feb 05, 2014 @ 18:00
    wayne nixon
    0

    No still no luck really is becoming a pain now

     

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 06, 2014 @ 17:15
    Jeavon Leopold
    0

    Hi Wayne,

    I think this is going to be a complex issue to trace down.

    Maybe as workaround you could try using .Count instead.

    if (nodes == null || nodes.Count() == 0)
    {
        return;
    }
    

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft