Sitecore 8.1 rev. 160302.

Looking into my logfiles, there are lots of errors such as:

Job Started: Index_Update_IndexName=RSearch
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: System.Web
at System.Web.Security.Roles.IsUserInRole(string username, string roleName)
at Sitecore.Security.Accounts.RolesInRoleProvider.IsUserInRole(User user, Role targetRole, Boolean includeIndirectMemberships)

This is just about everytime an index rebuild is triggered. Its almost identical to this: https://community.sitecore.net/developers/f/8/t/549 that seems to remain unresolved.

I've been over the security/roles with a fine-tooth comb and come up with nothing.

Any help will be massively appreciated. ty


Fixed with the help of Sitecore support. It turned out to be a conflict with .net 4.5.2 and IIS tracing. In brief, the Sitecore crawler ends up in System.Web.Security.Roles.IsUserInRole where there are these lines of code:

public static bool IsUserInRole(string username, string roleName)
    bool flag3;
    if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(4, 8))
        EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_BEGIN, HttpContext.Current.WorkerRequest);

Basically, there's no null guard on HttpContext.Current which turns out to be null for the crawler. With IIS Failed Request Tracing enabled, the code ventured into the if branch and choked.

The fixes are:

  1. Turn IIS tracing off OR
  2. Turn down the verbosity of IIS tracing from VERBOSE to WARNING OR
  3. Upgrade to .Net Framework 4.6.1 onwards (this contains a null guard check on HttpContext.Current in the System.Web DLL)
  • Can you post the whole stacktrace? – Marek Musielak Apr 17 '19 at 12:41
  • @MarekMusielak, I can't unfortunately. It's in an environment where I can't copy/paste. It seems to kick off Sitecore.Jobs.Job.ThreadEntry which throws up to Sitecore.ContentSearch.AbstractSearchIndex.PerformUpdate which throws up to Sitecore.ContentSearch.SitecoreItemCrawler.Update. The rest of the stacktrace is almost identical to that in the community page I linked to. – stuartw87 Apr 17 '19 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.