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” error message. 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.
Related Articles
To learn why your business should migrate to SharePoint Online and Office 365, click
here and
here.
If you want to convert your tenant’s root classic site into a modern SharePoint site, click
here.
If you or your customers are not ready to move entirely to the Cloud and Office 365, a hybrid scenario could be an interesting scenario and SharePoint 2019 RTM was recently announced with improved hybrid support! To learn all about SharePoint 2019 and all its features, click
here.
If you want to know all about the latest SharePoint and Office 365 announcements from SharePoint Conference 2019, click
here and
here.
If you are a SharePoint administrator or a SharePoint developer who wants to learn more about how to install a SharePoint 2019 farm in an automated way using PowerShell, I invite you to click
here and
here.
If you want to learn how to upgrade a SharePoint 2013 farm to SharePoint 2019, click
here and
here.
If you want to learn all the steps and precautions necessary to successfully keep your SharePoint farm updated and be ready to start your move to the cloud, click
here.
If you learn how to greatly speed up your SharePoint farm update process to ensure your SharePoint farm keeps updated and you stay one step closer to start your move to the cloud, click
here.
If SharePoint 2019 is still not an option, you can learn more about how to install a SharePoint 2016 farm in an automated way using PowerShell, click
here and
here.
If you want to learn how to upgrade a SharePoint 2013 farm to SharePoint 2019, click
here and
here.
If you are new to SharePoint and Office 365 and want to learn all about it, take a look at these
learning resources.
If you are work in a large organization who is using Office 365 or thinking to move to Office 365 and is considering between a single or multiple Office 365 tenants, I invite you to read
this article.