SharePoint: Error when adding a new page based on a customized (broken) page layout

Exception:

No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)  

image

Some interesting bits in the stack trace:

... at System.Activator.CreateInstance(Type type)

... at Microsoft.SharePoint.WebPartPages.SPWebPartSerializer.get_DefaultControl()

... at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)

snipped remaining massive stack trace.

What had happened was that we had a stuffed up Page Layout with a web part zone that contained invalid HTML.

I had detected this and deleted the entire web part zone, but SharePoint must have it in the database, so each time I re-open the PageLayout it was resurrecting all the broken code.

The fix wasn't at all glamorous:

  1. Check out the page layout
  2. Fix it enough in the code view so that the designer will load the designer view
  3. Delete the webparts in the designer view
  4. Switch back to the code view - there's now a few remaining bits of broken HTML left around the web part zone - fix those.
  5. Save everything
  6. Close file, re-open it
  7. Check the file is now clean HTML

We can now use the page layout to create new pages again.

jliu