Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
How are you creating the web part page in the first place? –  James Love Jul 26 '11 at 8:12
    
@James: All the variants have been created in Visual Studio 2010, as it needs to be part of a package. –  Stuart Pegg Jul 26 '11 at 8:16
    
As Modules yeah? –  James Love Jul 26 '11 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? –  Stuart Pegg Jul 26 '11 at 8:28

1 Answer 1

up vote 1 down vote accepted

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:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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