• Not Answered

"Object reference not set to an instance of an object" after installing 9.3 and my assemblies

I broke my local installation of Sitecore so I decided to install a clean version of 9.3. I added my own project back in but now I'm getting the errors above, any ideas? Happy to provide code snippets if needed. 

@using Sitecore.Mvc
@using Sitecore.Mvc.Analytics.Extensions
@using Sitecore.Mvc.Presentation
@using TAC.Utils
@using TAC.Utils.Helpers
@model RenderingModel
@{
    Layout = "~/Views/Guard/Layouts/_Head.cshtml";

    var decorationBannerUrl = Html.SitecoreMediaUrl(Statics.FieldNames.DecorationBanner);
    var mobileBannerUrl = Html.SitecoreMediaUrl("MobileBanner");


    var headerCssClass = "page-header";
    var headerBackgroundStyle = "";
    var mobileBackgroundStyle = "";

    if (!String.IsNullOrEmpty(decorationBannerUrl))
    {
        headerCssClass = headerCssClass + " " + "bg-media bg-parallax";
        headerBackgroundStyle = string.Format("background-image: url('{0}')", decorationBannerUrl);
    }
    if (!String.IsNullOrEmpty(mobileBannerUrl))
    {
        headerCssClass = headerCssClass + " " + "bg-media bg-parallax";
        mobileBackgroundStyle = string.Format("background-image: url('{0}')", mobileBannerUrl);
    }
    else
    {
        if (!String.IsNullOrEmpty(decorationBannerUrl))
        {
            // no special mobile image exists so fall back to the desktop header image
            headerCssClass = headerCssClass + " " + "bg-media bg-parallax";
            mobileBackgroundStyle = string.Format("background-image: url('{0}')", decorationBannerUrl);
        }
    }

}
<div id="main-container">
    <header class="siteheader">
        @Html.Sitecore().Placeholder(Statics.PlaceholderKeys.HeaderNavigation)
    </header>
    <main role="main"> 
        <div class="visible-lg visible-md">
            @using (Html.BeginHeader(new { @class = headerCssClass, style = headerBackgroundStyle }))
            {
                @Html.Sitecore().Placeholder(Statics.PlaceholderKeys.HeaderContent)
            }
        </div>
        <div class="visible-sm visible-xs">
            <div>
            @using (Html.BeginHeader(new { @class = headerCssClass, style = mobileBackgroundStyle }))
            {
            }
            </div>
            @Html.Sitecore().Placeholder(Statics.PlaceholderKeys.HeaderContent)
        </div>
        <section class="section section-full">
            @Html.Sitecore().DynamicPlaceholder(Statics.PlaceholderKeys.MainContent)
        </section>
    </main>
    <div>
                @Html.Sitecore().Placeholder(Statics.PlaceholderKeys.FooterContent)          
    </div>
</div>

using System;
using System.Text.RegularExpressions;
using Sitecore.Data.Items;
using Sitecore.Links;

namespace TAC.Utils.Helpers
{
    public class CustomLinkProvider : Sitecore.Links.LinkProvider
    {
        public override string GetItemUrl(Item item, UrlOptions options)
        {
            string query = String.Format("/*/system/Aliases//*[@@templateid='{0}' and contains(@Linked item, '{1}')]", Sitecore.TemplateIDs.Alias, item.ID);
            Sitecore.Data.Items.Item alias = Sitecore.Context.Database.SelectSingleItem(query);
            string aliasUrl = string.Empty;
            if (alias != null)
            {
                aliasUrl = base.GetItemUrl(alias, options);
                //remove the system part of the url that is returned.
                aliasUrl = Regex.Replace(aliasUrl, @"/sitecore/system/aliases", "", RegexOptions.IgnoreCase);
                aliasUrl = aliasUrl.Replace("-", " ");
                return aliasUrl;
            }
            else
            {
                return base.GetItemUrl(item, options);
            }
        }
    }
}

I'm not sure why this is suddenly an issue as there were no issues with these views/assemblies before the update.

4 Replies