Use the FeatureDefinitions property of the SPFarm class to get the collection of Feature definitions that are installed in the server farm. To add a Feature definition to the collection, use one of the SPFeatureDefinitionCollection methods of the SPFeatureDefinitionCollection class. Adding a Feature to the collection installs the Feature in the server farm, making it available for activation in its specified scope. Adding a Feature that has farm scope not only installs the Feature, but activates it within the farm.
Use an indexer to return a single Feature definition from the collection. For example, if the collection is assigned to a variable named myDefinitions, use myDefinitions[index] in C#, or myDefinitions(index) in Visual Basic, where index is the Guid of the Feature.
Caution: |
|---|
|
You cannot use the SPFeatureDefinition constructor to create a Feature definition object. This is not supported and returns a NullReferenceException if you attempt to implement members of an object created through the constructor.
|