Monday, October 18, 2021

Custom left navigation broken - Aug 21 Cumulative Updates SharePoint 2016

 

We have a SharePoint 2016 Publishing site with custom left navigation webpart rendering a treeview implemented using <asp:SiteMapDataSource />, <asp:TreeView /> and PortalSiteMapProvider. It was built during MOSS 2007 days, part of the custom site definitions, and carried over through the upgrades. It has been working great since.

I recently installed August 2021 CU and the treeview stopped rendering. Simple rendering "Error" and no exception thrown. 

I spent good amount of troubleshooting and changing the SiteMap providers in the web.config without much luck. The treeview is working fine with all other SiteMapProviders except our custom navigation provider. Looked into ULS found the below errors:

PortalSiteMapProvider was unable to fetch root node, request URL: /xxx/xxx/default.aspx, message: Object reference not set to an instance of an object., stack trace:   

 at Microsoft.SharePoint.Publishing.CacheManager.GetManager(SPSite site, Boolean useContextSite, Boolean allowContextSiteOptimization, Boolean refreshIfNoContext)    

 at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.get_ObjectFactory()    

 at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.GetRootNodeCore() 

Unable to access this sensitive property : CurrentSite from outer untrusted assembly:Microsoft.SharePoint.Publishing, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Trusted assembly list:

PortalSiteMapProvider was unable to fetch current node, request URL: /xxx/xxx/default.aspx, message: Object reference not set to an instance of an object., stack trace:   

 at Microsoft.SharePoint.Publishing.CacheManager.GetManager(SPSite site, Boolean useContextSite, Boolean allowContextSiteOptimization, Boolean refreshIfNoContext)    

 at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.get_ObjectFactory()    

 at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.get_CurrentNode()


Fix:

Add the following entries to the web.config in SharePoint Web application virtual directory. I had to add the custom navigation assembly entry and the Microsoft's own SharePoint Publishing assembly entry to resolve the issue. 

<SharePoint>
<SafeMode>
<AllowAccessSensitivePropertiesAssemblies>

<AllowAccessSensitivePropertiesAssemblies>

        <AllowAccessSensitivePropertiesAssembly Assembly="YourCustomSiteNavigation, Version=x.x.x.x, Culture=xxxxx, PublicKeyToken=xxxxxxxxx"/>

       <AllowAccessSensitivePropertiesAssembly Assembly="Microsoft.SharePoint.Publishing, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/>

      </AllowAccessSensitivePropertiesAssemblies>


</AllowAccessSensitivePropertiesAssemblies>

</SafeMode>

</SharePoint>


Our environment is SharePoint 2016, so the Publishing DLL Version shown above is 16.0.0.0. Change the appropriate DLL version to match your SharePoint version, and the culture too, if different. 

Reference:

https://blog.stefan-gossner.com/2021/08/10/common-error-unable-to-access-this-sensitive-property-8gaol-logged-in-uls-after-installing-june-2021-cu-or-later/

https://support.microsoft.com/en-us/topic/user-code-might-be-blocked-when-third-party-assemblies-access-sensitive-properties-kb5004581-1883611f-2f0b-4280-8b38-909fdf4fd659

https://support.microsoft.com/help/5002002