I'm attempting to create a web part page from scratch, but I keep running into the following error, which occurs post-Init:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   Microsoft.SharePoint.WebPartPages.WebPartResultSet.get_PartOrder() +77
   Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts) +6693
   Microsoft.SharePoint.WebPartPages.SPWebPartManager.LoadWebParts() +146
   Microsoft.SharePoint.WebPartPages.SPWebPartManager.OnPageInitComplete(Object sender, EventArgs e) +288
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnInitComplete(EventArgs e) +11056990
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1674

I have tried:

  • Using default.master
  • Not using default.master (adding an SPWebPartManager to the page)
  • Creating the page as a module of a web part
  • Creating the page in the _layouts folder
  • Creating the page as a component of a list definition
  • Zones: Single, Multiple, None
  • Web Parts: Single, Multiple, None, Inside Zones, outside Zones
  • Opening an UI-created Web Part Page in Designer, copying out the contents, and pasting them into a file
  • Inheriting from Microsoft.SharePoint.WebPartPages.WebPartPage
  • Inheriting from a code-behind class that inherits from Microsoft.SharePoint.WebPartPages.WebPartPage
  • With and without code behind
  • Googling the error's source function (nothing)
  • Examining the function with Reflector (apparently the WebPartResultSet is null, but I can't find why)

The Madness is calling (baa). Please help.

  • How are you creating the web part page in the first place?
    – James Love
    Jul 26, 2011 at 8:12
  • @James: All the variants have been created in Visual Studio 2010, as it needs to be part of a package.
    – Stu Pegg
    Jul 26, 2011 at 8:16
  • As Modules yeah?
    – James Love
    Jul 26, 2011 at 8:18
  • @James: Yes in the case of the page attached to a web part, and also for one of the prototype pages included in a List Definition. Is it necessary to wrap such a page in a Module?
    – Stu Pegg
    Jul 26, 2011 at 8:28

2 Answers 2


So, it seems the Module is necessary and has to be correctly configured. Most of my problem above was not knowing about having a Module, and the rest by not having it set up properly.

Here are some useful links on the matter; a mashup of which I used the create the eventual solution:


A bit late and on Sharepoint 2010, but: I fixed similar error when deploying a list definition feature without any pages or webparts, but with list views associated with such, by adding simple "WebPartZoneID="Main"" to a view def.

<View DefaultView="TRUE"
        DisplayName="Last modified" 

Important parts are SetupPath, WebPartZoneID and BaseViewID. This code (and the view definition below it, of course) creates a kind of "default" list view page, that could be referenced then by shown URL. The page contains only the specified list in specified view. Seems way better than deploying a web part page via module.

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.