Archive

Posts Tagged ‘site-definition’

Problem with VS2010 beta 2 Site Definition

December 16th, 2009 Jeffrey Tummers 3 comments

I encountered the following problem while creating a new custom Site Definition in Visual Studio 2010 beta 2.

The problem occurs when trying to create a new Document Library in the site based on the custom Site Definition.

Error while trying to add a new Document Library

Error while trying to add a new Document Library

Error message:

Error

An error occurred while getting items from the "" provider:
Cannot complete this action.

Please try again.

Read on to see the solution for this error.

Visual Studio 2010 now has native integration of SharePoint 2010 projects.

New Site Definition in Visual Studio 2010

New Site Definition in Visual Studio 2010

After creating the new Site Definition Project in the onet.xml file contains the following:

<?xml version="1.0" encoding="utf-8"?>
<Project Title="SampleSiteDefinition" Revision="2" ListDir="" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/">
  <NavBars>
  </NavBars>
  <Configurations>
    <Configuration ID="0" Name="SampleSiteDefinition">
      <Lists/>
      <SiteFeatures>
      </SiteFeatures>
      <WebFeatures>
      </WebFeatures>
      <Modules>
        <Module Name="DefaultBlank" />
      </Modules>
    </Configuration>
  </Configurations>
  <Modules>
    <Module Name="DefaultBlank" Url="" Path="">
      <File Url="default.aspx">
      </File>
    </Module>
  </Modules>
</Project>

Now you can modify to the onet.xml and default.aspx as you like.

When deploying the new Site Definition, creating a site, and then trying to create a new Document Library you get the error above.  The solution for the error turned out to be the missing declaration of the <DocumentTemplates> XML node.

Correct default onet.xml should be:

<?xml version="1.0" encoding="utf-8"?>
<Project Title="SampleSiteDefinition" Revision="2" ListDir="" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/">
  <NavBars>
  </NavBars>
  <DocumentTemplates>
  </DocumentTemplates>
  <Configurations>
      <Lists/>
      <SiteFeatures>
      </SiteFeatures>
      <WebFeatures>
      </WebFeatures>
      <Modules>
        <Module Name="DefaultBlank" />
      </Modules>
    </Configuration>
  </Configurations>
  <Modules>
    <Module Name="DefaultBlank" Url="" Path="">
      <File Url="default.aspx">
      </File>
    </Module>
  </Modules>
</Project>

After re-deploying the Site Definition and creating a new Site, you are able to create a Document Library.

Working new Document Library

Working new Document Library

Reference:

Microsoft’s Reference for SharePoint 2010 onet.xml

Looking for SharePoint 2010 Feature (GU)IDs

December 15th, 2009 Jeffrey Tummers 1 comment

Have you ever been looking for a feature (GU)ID in SharePoint? Well here is an easy way to find them.

I needed default SharePoint feature guids for the development of a custom Site Definition. Using a custom Site Definition you can automatically activate SharePoint features within the onet.xml file.

Here we go:

  1. Open the SharePoint site in IE8 (or IE7).
  2. Go to the Site Settings page.
    site-settings-menu
  3. Click on the Manage Site features (or Site Collection features)
    site-features
  4. Use the Developer Tools (shortcut F12)
  5. Click in the toolbar on Find –> Select Element by Click (shortcut CTRL+B, but this opens bookmarks manager on my machine)
    developertools-select
  6. Select the Activate (or Deactivate) button next to the feature you need the GUID from.
    select-feature-activate-button
  7. Developer Tools scrolls down to the HTML source for the specific button, the button tag is contained within a Div tag. This Div tag contains an ID attribute and thats the GUID for the feature!
    selected-feature-html
  8. In this case the GUID is: 9c03e124-eef7-4dc6-b5eb-86ccd207cb87
    selected-feature-guid

This trick also works for SharePoint 2007!