SPFeatureDefinitionCollection.Add method (String, Int32, Guid, Boolean)
Adds the Feature definition with the specified manifest path, compatibility level and solution ID to the collection of Feature definitions, including a Boolean parameter that specifies whether to force reinstallation of the Feature definition.
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Function Add ( _
relativePathToFeatureManifest As String, _
compatibilityLevel As Integer, _
solutionId As Guid, _
force As Boolean _
) As SPFeatureDefinition
'Usage
Dim instance As SPFeatureDefinitionCollection
Dim relativePathToFeatureManifest As String
Dim compatibilityLevel As Integer
Dim solutionId As Guid
Dim force As Boolean
Dim returnValue As SPFeatureDefinition
returnValue = instance.Add(relativePathToFeatureManifest, _
compatibilityLevel, solutionId, _
force)
public SPFeatureDefinition Add(
string relativePathToFeatureManifest,
int compatibilityLevel,
Guid solutionId,
bool force
)
Parameters
relativePathToFeatureManifest
Type: System.StringA string that contains the relative path to the manifest for the Feature.
compatibilityLevel
Type: System.Int32An integer that represents the feature compatibility level, e.g. 14 or 15
solutionId
Type: System.GuidSystem.Guid that identifies the solution.
force
Type: System.Booleantrue to specify that reinstallation of the Feature definition be forced; otherwise, false.
Return value
Type: Microsoft.SharePoint.Administration.SPFeatureDefinition
A Microsoft.SharePoint.Administration.SPFeatureDefinition object that represents the new Feature definition.
Remarks
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.Warning: Using the SPFeatureDefinition constructor to create a Feature definition object is not supported, it returns a NullReferenceException if you attempt to implement members of an object created through the constructor.
See also
Reference
SPFeatureDefinitionCollection class