天天看點

使用 WSPBuilder 建立List Instance WSP 包

  1. Project structure



使用 WSPBuilder 建立List Instance WSP 包

  2. Feature xml

     <?xml version="1.0" encoding="utf-8"?>

   <Feature  Id="C257B7BE-D5F3-4b9d-B146-5F13F2E96AE9"

          Title="CreateAnnouncementList"

          Description="Description for CreateAnnouncementList"

          Version="12.0.0.0"

          Hidden="FALSE"

          Scope="Web"

          DefaultResourceFile="core"

          xmlns="http://schemas.microsoft.com/sharepoint/">

    <ElementManifests>

      <ElementManifest Location="elements.xml"/>

      <ElementFile Location="AnnouncementsList/schema.xml"/>

    </ElementManifests>

   </Feature>

  3. Elements xml

 <?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <ListTemplate

    FeatureId="C257B7BE-D5F3-4b9d-B146-5F13F2E96AE9"

    Name="AnnouncementsList"

    DisplayName="AnnouncementsList"

    Description=""

    BaseType="0"

    Type="100"

    OnQuickLaunch="TRUE"

    SecurityBits="11"

    Sequence="410"

    Image="/_layouts/images/itgen.gif" />

  <ListInstance

    FeatureId="C257B7BE-D5F3-4b9d-B146-5F13F2E96AE9"

    Title="AnnouncementsList"

    Url="Lists/AnnouncementsList"

    Description="AnnouncementsList"

    TemplateType="100" />

  </Elements>

  4 . Note:

Element xml 檔案中的ListTemplate 的Name 的名稱必須和包含Schema.xml的檔案夾名稱保持一緻。否則在激活Feature時會報錯。錯誤資訊如下:

Exception from HRESULT: 0x81070201   at Microsoft.SharePoint.Library.SPRequestInternalClass.CreateList(String bstrWebUrl, String bstrTitle, String bstrDescription, String bstrListUrl, String bstrFeatureId, Int32 lTemplateID, String bstrDocTemplateType, ListQuickLaunchOptions qlOpt)

   at Microsoft.SharePoint.Library.SPRequest.CreateList(String bstrWebUrl, String bstrTitle, String bstrDescription, String bstrListUrl, String bstrFeatureId, Int32 lTemplateID, String bstrDocTemplateType, ListQuickLaunchOptions qlOpt)

ListTemplate和ListInstance檔案的FeatureId 與Feature 檔案保持一緻。

轉載于:https://www.cnblogs.com/dexter2003/archive/2011/06/08/2075394.html