One of my client having a requirement that to create sub
sites programmatically using SharePoint site template location in solution gallery.
We need to create a site with some lists and libraries and save it as site
template by navigating to site settings and clicking on save site as template
link. By doing this I got an error saying that,
Enable-SPFeature –Identity ctypes –url “Site Collection URL”
Error exporting the list named “Announcements” at the URL:
Lists/Announcements
Tried to rename the
list, but got the same error with another list. By Checking the logs I have found
the error message below,
SPSolutionExporter:
System.NullReferenceException: Object reference not set to an instance of an
object.
After some
troubleshooting on the issue, I have found that few of custom content types not
set to defaults in site and site collection level.
To fix this issue
run the following power shell commands to disable and enable the content type
feature.
Disable-SPFeature
–Identity ctypes –url “Site Collection URL”
Enable-SPFeature –Identity ctypes –url “Site Collection URL”
After running this
power shell commands there is no change in content types. Now we can save
the site template with out any issues.