2

I am running into an issue for a site we are upgrading from 8.1 to 9.0.1. In the process of refactoring and updating the code base, we have upgraded Glass from v3 to v4.5. After doing so, every Glass getitem (GetCurrentItem, queries, etc - everything) returns null. I've seen similar posts on StackOverflow that mention language fallback as a likely culprit but the site language is set to "en" in our site configuration and when debugging the Sitecore.Context.Language is set to "en".

For further context, we've even tried taking DI and other factors out of the equation by setting up a test page on the site. This also returns a null object.

<%
    var sitecoreContext = new Glass.Mapper.Sc.SitecoreContext();
    var itemId = new Guid("{861C0CDA-FF19-4F1B-BB4C-B65C8E3DA724}");

    Sitecore.Context.Language = Sitecore.Data.Managers.LanguageManager.GetLanguage("en");

    using (new Sitecore.SecurityModel.SecurityDisabler())
    {
        var item = sitecoreContext.GetItem<Sitecore.Data.Items.Item>(itemId);
        Response.Write(item.Name); //this is null exception b/c item is null
    }
%>

(You'll notice that we are trying SecurityDisabler here as well to make sure that permissions isn't the problem. I'll also note that straight Sitecore API calls work fine.)

Update:

Maybe a clue from FallbackCheckTask (which I actually don't think we need anymore but that is a different concern):

enter image description here

The args.Result here is null but scContext.Item looks correct. Why is the result null? Any ideas on how to dig deeper into that?

2
  • does glass still return a model, i.e. not an Item object? Is it specific to items objects? Commented Oct 25, 2018 at 12:46
  • No object returned and it's not specific to any type of object. I tried using the Sitecore item object in the above example to try to reduce the number of things that would be wrong.
    – sestocker
    Commented Oct 25, 2018 at 14:09

1 Answer 1

3

This fix will probably not apply to many others - but our issue was that some of our Visual Studio projects were directly referencing v3 Glass dll's (we aren't sure how this happened as both v3 and v4.5 were referenced using nuget). Because of the conflict between versions, Glass just didn't work at all. Once we removed the old references, everything worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.