Showing posts with label PageLayout. Show all posts
Showing posts with label PageLayout. Show all posts

Saturday, 14 February 2009

No Parameterless Constructor defined for the Object

So we had created a new Web Part and using SharePoint Designer we put it on to a pagelayout, then deployed as a Feature.

Fantastic

Then when creating a page based on the layout we got this error "No Parameterless Constructor defined for the Object"

So a bit of digging on the internet (and reading the error message) we discover that the problem can be caused by the Web Part not having a Constructor without any parameters.

Something like this.

namespace WebPart1
{
[Guid("4547a00e-f630-4117-922e-f075866be9ec")]
public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
public WebPart1()
{
}
}
}


However the code did have a parameterless constructor. So I spent the next couple of hours adding parameterless constructors to all of the class files.

Unfortunately this was still to no avail.

Eventually I got to the point when I uninstalled the feature, then completely into Central Admin, retracted the solution, then deleted it.

Then deleted the feature folder in the 12 hive (c:\Program Files\Common Files\Microsoft Shared\web server extensions)

Then re-installed the feature et voila!

So I suspect SharePoint had done some caching along the way, and it was only by doing an uninstall was this error cleared from it's cache.