0
votes

FormServerTemplates

Style Library

SiteCollectionImages

Pages

I got few default sharepoint libraries where and "library settings" click i got exception:

enter image description hereSystem.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.ApplicationPages.ListEditPage.OnLoad(EventArgs e) at ASP._layouts_listedit_aspx.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

All my investigations shows that this problem because DocumentTemplateUrl is null!

this.strDocTemplateURL = "";
  if (this.iBaseType == SPBaseType.DocumentLibrary)
  {
    this.strDocTemplateURL = ((SPDocumentLibrary) this.spList).DocumentTemplateUrl;
    this.DocumentLibraryGeneralLinks.Visible = true;
  }
  if (this.strDocTemplateURL.Length != 0)

But one very important note that this bug appears only with custom masterpage!

Default v4 masterpage working without any problems.

Any ideas what can cause a problem there?

2

2 Answers

1
votes

Without going through your master page, my guess would be that there is some javascript missing from the custom master page. What I would try is to compare the HTML page source when rendering using the v4 master page versus the rendered output with your custom master page. I would then compare the javascript - not just in the head section and on the bottom of the page but throughout. I would especially compare the ContextInfo object assignments and make sure those properties are being assigned to similar values.

My thought is that there is some javascript code or reference that the Library Settings button expects, but can't find, and that is what is causing the error.

0
votes

This is very strange problem or strange exception at least. But was found control on custom masterpage that can cause this exception.

Was located two lines of code that can cause problem on that settings page:

1) web.Lists.TryGetList(listTitle);

2) RightsSensitiveVisibilityHelper.UserHasRights(PermissionContext.CurrentSite, SPBasePermissions.AddListItems, PermissionMode.Any, list);

There is no exception but if we will use one of those methods than exception will appear!

I think that this bug because webpart contains strange code in OnLoad method where its ensuring child controls and creating header:

 protected override void OnLoad(EventArgs e)
    {
        try
        {
            base.OnLoad(e);
            this.EnsureChildControls();
            this.InitWebPartHeader();
        }
        catch (Exception ex)
        {
            this.Controls.Clear();
            this.Controls.Add(new LiteralControl(ex.Message));
        }
    }

I don’t know why we have this code but also comments located there “Ensures that the CreateChildControls() is called before events.”.

So I hope this will save time for people that searhing for same error.