Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a problem when I activate the feature on the subsite. I try to create a wsp package with the module and feature. In the module I have stp files (list templates).

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="Module_Template" Url="_catalogs/lt">
        <File Path="Module_Template\Stp\myTemplate1.stp" Url="myTemplate1.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
            <Property Name="LanguageDisplay" Value="1033" />
        </File>
        <File Path="Module_Template\Stp\myTemplate2.stp" Url="myTemplate2.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
            <Property Name="LanguageDisplay" Value="1033" />
        </File>
    </Module>
</Elements>

There is my Feature.xml

  <Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="MyFeature Install Modules" Id="1c68d642-89ad-49ee-bfe1-38aac06272ee" ReceiverAssembly="MyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1fea90db2a1bbfe5" ReceiverClass="MyFeature.Features.Feature1.Feature1EventReceiver" Scope="Web">
      <ElementManifests>
        <ElementManifest Location="Module_Template\Elements.xml" />
        <ElementFile Location="Module_Template\Stp\myTemplate1.stp" />
        <ElementFile Location="Module_Template\Stp\myTemplate2.stp" />
      </ElementManifests>
    </Feature>

If I activate my feature on WebRootSite the files from module copy to List Templates correct. But if I activate the feature on subsite i get an exception:

threw an exception during activation: Failed to instantiate file "myTemplate1.stp" from module "Module_Template": The specified list does not exist.

If I add the property (to Module) RootWebOnly="True" there is no exception but the files do not copy to the List Templates on the server. What im doing wrong?

share|improve this question
    
Off Topic for Stack Overflow. Ask this on SharePoint. –  Kyle Trauberman Feb 21 '12 at 14:10
add comment

migrated from stackoverflow.com Feb 21 '12 at 14:29

This question came from our site for professional and enthusiast programmers.

1 Answer

List template gallery (the url atribute of _catalogs/lt) is only available in the root web of the site collection. So you get an exception when the feature is activated in the subsite because it cannot find the specified list (http://sitename/subsitename/_catalogs/lt). The templates should be available across the site collection.

Change the feature scope to site and deploy again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.