如果自定义解决方案符合您的要求,那么您可以尝试以下方法来查找已激活的功能版本。
- 使用 SPFarm.FeatureDefinitions
获得农场中所有激活的功能 -
SPFeatureDefinitionCollection farmFeatures = SPFarm.Local.FeatureDefinitions;
foreach (SPFeatureDefinition feature in farmFeatures)
{
....
}
查找特定功能的版本
var spFarm = SPFarm.Local;
System.Version version = spFarm.FeatureDefinitions["YourFeatureName"].Version;
使用 SPContext.Current.SiteFeatures 或 SPContext.Current.Site.Features
var siteFeatures= SPContext.Current.SiteFeatures;
foreach (SPFeature sf in siteFeatures)
{
变量 = sf.Definition.DisplayName;
variable = sf.Definition.Version.ToString();
}
4 使用 SPContext.Current.WebFeatures 或 SPContext.Current.Web.Features
var webFeatures= SPContext.Current.WebFeatures;
foreach (SPFeature webFtr in webFeatures)
{
variable= webFtr.Definition.DisplayName;
variable= webFtr.Definition.Version.ToString();
}
希望这可以帮助。