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)
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:
- Check out the page layout
- Fix it enough in the code view so that the designer will load the designer view
- Delete the webparts in the designer view
- Switch back to the code view - there's now a few remaining bits of broken HTML left around the web part zone - fix those.
- Save everything
- Close file, re-open it
- Check the file is now clean HTML
We can now use the page layout to create new pages again.
jliu