2

I am attempting to call SPListCollection.EnsureSitePagesLibrary() upon FeatureActivated. The method is throwing the following exception:

Microsoft.SharePoint.SPException: A list, survey, discussion board, or document library with the specified title already exists in this Web site. Please choose another title.

If I check for the list: if (lists.TryGetList("Site Pages") == null) before the call to EnsureSitePagesLibrary(), the method is still executed and the exception is still thrown. Furthermore, when browsing the site through SharePoint Manager 2010, there is no sign of the Site Pages library. Can someone help explain this behavior?

Thanks!

3
  • Please make sure to reply on here and mark answers as the answer that addressed your issue. Otherwise this could lead to other community members not wanting to address your questions. Thanks. Commented Feb 13, 2013 at 19:00
  • 1
    I appreciate your input. I ended up taking a different direction since the SPListCollection.EnsureSitePagesLibrary() method simply does not work unless the "Wiki Page Home Page" is activated, which I did not want activated. I ended up using a standard document library called "Pages". If you add this to your answer, I'll mark it as the accepted answer. Commented Feb 14, 2013 at 21:00
  • Added it as a foot note to my proposed answer for the other folks who may not want that feature enabled. Glad to hear it is squared away for you. Commented Feb 19, 2013 at 18:26

1 Answer 1

1

A few possible steps you can try:

  1. Check to ensure your "Wiki Page Home Page" feature is activated.
  2. SharePoint Designer 2010 can create the libraries for you.

    A. Open SharePoint Designer

    B. In the "Site Objects" pane on the left, click "Site Pages". SPD will load the contents of the Site Pages library and tell you it is empty. However, it also creates the Site Pages library for you in the process.

    C. Do the same thing for "Site Assets".

  3. Open your site with SPD and click "All Files" on the left. Check there to determine if the folder or library already exists. If so, that is your problem.

Give those steps a try and let me know if this helps.

EDIT: The original poster did not want the Wiki Page Home Page feature activated so they simply added a library called "Pages". So that works too if you don't want that feature turned on.

4
  • Checked all 3. The "Wiki Page Home Page" feature is not activated. And I checked with SPD+SPM to ensure that the library was not already created. Commented Jan 16, 2013 at 18:42
  • If you activate the "Wiki Page Home Page" feature do you still have the same problem? Commented Jan 17, 2013 at 13:24
  • I didn't want the wiki features enabled. Commented Feb 14, 2013 at 20:56
  • 1
    The 'Wiki Home Page' feature can be de-activated: the home page change is undone but the SitePages and SiteAssets remain. Also, in my testing the EnsureSitePages/EnsureSiteAssets do work, even without the Wiki feature. What probablyl happens is that your feature deploys to SitePages before the library is there: this will cause a folder to be created with the same name: your files are deployed but the EnsureSitePages will now fail.
    – ErikE
    Commented Apr 24, 2013 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.