문제

Iam deploying solution to site scoped feature , and in feature activated event receiver iam writing the code to activate feature to all subsites but error is "feature is site-scoped and cannot be added to the web sharepoint 2010 " and code is

using (SPSite osite = properties.Feature.Parent as SPSite)
                    {
                        Guid featureGuid = new Guid(xxxxxxxxxxxxx);
                        foreach (SPWeb webs in osite.AllWebs)
                        {
                            webs.Features.Add(featureGuid);
                        }

                    }
도움이 되었습니까?

해결책

Site features (here site means "site collection", while web means root-site/sub-site) can only be activated at a site-collection level (i.e. from the root-site of a collection, under the "Site collection features" page).
Site features produce their effects on the entire site collection. For instance:

  • If it contains a custom action, the custom action is visible in all sub-sites.
  • If it contains a Web part, the Web part is provisioned in the site collection Web part galery (located at the root-level) and is then available for all sites in the collection.

Some artifacts cannot be scoped site (see list at msdn).

So, either your feature is site scoped, or it's web scoped. There's no point at all in trying to activate a site feature at a web level. And it's not your responsibility to activate a site feature on all sub-sites: intrinsically, the site feature impacts all sites (webs) of the collection.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top