【问题标题】:turn on site collection features programatically sharepoint csom以编程方式打开网站集功能 sharepoint csom
【发布时间】:2016-03-12 17:10:54
【问题描述】:

我正在尝试使用 CSOM 在我们的本地环境中以编程方式打开网站集功能。

我不断收到错误: Feature with Id '7201d6a4-a5d3-49a1-8c19-19c4bac6e668' is not installed in this farm, and cannot be added to this scope.

我通过 GUI 检查网站集功能,它在那里,所以我认为它已打开(并且它是 OOTB)。

为什么会这样?

代码:

try
          {
            if (featureNode.Attributes != null)
            {
                string guid = featureNode.Attributes["ID"].Value;
                string featureName = featureNode.Attributes["FeatureName"].Value;

                 Guid featureGUID = new Guid(guid);
                 if (isSiteColl)
                 {
                     currentFeatures.Add(featureGUID, false, FeatureDefinitionScope.Site);
                      currentContext.ExecuteQuery();
                  }
                  else
                  {
                      currentFeatures.Add(featureGUID, false, FeatureDefinitionScope.None);
                       currentContext.ExecuteQuery();
                   }
               }
          }

【问题讨论】:

    标签: .net sharepoint csom


    【解决方案1】:

    您尝试激活的功能是*元数据导航和过滤`,对吧?

    问题出在这部分代码中:

    if (isSiteColl)
    {
        currentFeatures.Add(featureGUID, false, FeatureDefinitionScope.Site);
        currentContext.ExecuteQuery();
    }
    else
    {
        currentFeatures.Add(featureGUID, false, FeatureDefinitionScope.None);
        currentContext.ExecuteQuery();
    }
    

    我不知道isSiteColl 的值是什么,因为它没有在您提供的代码中分配。但是对于元数据导航和过滤FeatureDefinitionScope.SiteFeatureDefinitionScope.None 都不对。

    此枚举指示功能 定义 的位置,而不是您要安装它的位置。正确的值是:

    • Farm 用于 OOB 功能以及作为自定义场解决方案的一部分安装的功能。
    • Site 用于将网站导出为模板时生成的沙盒解决方案和功能。

    这是基于我的经验。我一直在为同样的问题而苦苦挣扎,因为这在 MSDN 上的记录非常差。我不知道什么时候应该使用 WebNone 值。

    【讨论】:

      猜你喜欢
      • 2019-09-07
      • 2014-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 2015-06-22
      相关资源
      最近更新 更多