In a project I am currently working on, I needed to edit a page layout in a Publishing Site and I was adding a custom web part using SharePoint Designer. Everything seemed to be working fine (the web part was successfully added to the page) but when I browsed to the page, I got a "No parameterless constructor defined for this object". I checked the SharePoint trace logs (check my previous post on Diagnostic Logging for more information on this) and the following error message was written:
An unexpected error has been encountered in this Web Part. Error: Cannot create an object of type 'Microsoft.SharePoint.SPListItem' from its string representation ' Microsoft.SharePoint.SPListItem' for the 'CurrentItem' property.
The reason for this error to be shown was that SharePoint Designer was adding a CurrentItem property (a public property of the custom web part of type Microsoft.SharePoint.SPListItem) to the web part declaration:
<WebParts:MyCustomWebPart CurrentItem=" Microsoft.SharePoint.SPListItem" …/>
When the web part tried to access this property, the above error was thrown, because an instance of an object of type Microsoft.SharePoint.SPListItem was trying to be created from its string representation. Once I removed this property from the web part declaration, it started to work fine.
Posted
2007-11-18 10:42
by
Miguel Isidoro