Monday 19 April 2010

No parameterless constructor defined for this object when creating a new page

With everything working admirably in development I was greeted with the below error message when attempting to create a new page after today’s fresh deploy to UAT (and eventually prod, where I gave up):

Error No parameterless constructor defined for this object

No fun but luckily the problem was easily isolated and a work around arrived at—although I have yet to unearth the root cause.

By way of more detail, I was attempting to create a new page instance in a new sub site using a branded master page and page layout. This isn’t normally a problem and seems to be limited to this master page/layout combo as I can successfully create page instances in the same sub site using another layout known to be good. The problematic page layout contains a single rich text field and webpartzone but, unlike other posts discussing the same error message, the <zonetemplate> element is empty and I’m not attempting to deploy web parts to the page using the AllUsersWebPart crappiness. I just want my basic page!!

Most of the suggestions out there for resolving the above error lead you to the web part editor maintenance screen (see below) where you’ll find one or more ErrorWebParts, which can then be deleted. The problem with this approach is maintaining the page’s web parts requires the page layout to be checked out and that customises the layout, meaning future feature-based deployments of that layout won’t “take”. Of course, my layout isn’t supposed to have any web parts so go figure where the single mysterious ErrorWebPart originates… there seems to be a (related?) issue accessing web part programmatically in which ErrorWebParts objects are returned instead so I wonder if this is a different web part than how it’s represented…

Others suggest redeploying the layout after deleting it from the gallery but that didn’t work in my case.

In the end, I created a page from a different layout using the same content type as my desired page and then changing the layout. All fine from there but not at all usable—luckily this was for a short-lived campaign site.

How to open a page layout in web part maintenance mode

Just as a page instance can have web parts, a page layout can also have web parts. To manage those web parts, check out the layout within the Master Page Gallery, and click View Properties from the context menu. Next, edit the item and click the ‘Open Web Part Page in maintenance view’ link at the bottom of the page.

Alternatively, you can substitute your page layout in this URL:

http://<server>/_catalogs/masterpage/<page layout name>.aspx?contents=1

3 comments:

  1. Hi Michael,

    I had this problem today and found it was due to a capitalization mismatch in a start/end tag pair, such as this:

    <WebPartPages:WebPartZone>
    ...
    </WebPartPages:webpartzone>

    Unbelievably, when you enter a tag like this:

    <WebPartPages:WebPartZone ... />

    into SharePoint Designer 2010, it will automatically convert it to:

    <WebPartPages:WebPartZone ...>
    ...
    </WebPartPages:webpartzone>

    Best,
    Morten

    ReplyDelete
  2. @Morten: Interesting. I'm usually fairly pedantic about that sort of thing and avoid SPD like the plague but I checked the offending layout just in case. In my case the opening and closing tags are capitalised consistently. Haven't come up against this one again since my original post but the page in question was unusual in that it was using a non-standard layout copied from another campaign web site. Just noticed VS 2010 complaining about inconsistent line endings so hmmmm...

    ReplyDelete
  3. Thanks a lot sir...saved my day today :)

    ReplyDelete

Spam comments will be deleted

Note: only a member of this blog may post a comment.