Share via


SPFeatureCollection.Remove Method (Guid, Boolean)

Removes the Feature with the specified GUID from the collection and optionally ignores errors.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableExceptionConstraintAttribute(FixedId := "System.UnauthorizedAccessException$-2147024891",  _
    Condition := "User does not have the right of managing the site or site collection",  _
    ErrorType := GetType(UnauthorizedAccessException))> _
<ClientCallableMethodAttribute> _
<ClientCallableExceptionConstraintAttribute(FixedId := "System.InvalidOperationException$0",  _
    Condition := "The given feature is not an activated feature or the given feature cannot be deactivated and user does not force the operation",  _
    ErrorCode := , ErrorType := GetType(InvalidOperationException))> _
Public Sub Remove ( _
    featureId As Guid, _
    force As Boolean _
)
'Usage
Dim instance As SPFeatureCollection
Dim featureId As Guid
Dim force As Boolean

instance.Remove(featureId, force)
[ClientCallableExceptionConstraintAttribute(FixedId = "System.UnauthorizedAccessException$-2147024891", 
    Condition = "User does not have the right of managing the site or site collection", 
    ErrorType = typeof(UnauthorizedAccessException))]
[ClientCallableMethodAttribute]
[ClientCallableExceptionConstraintAttribute(FixedId = "System.InvalidOperationException$0", Condition = "The given feature is not an activated feature or the given feature cannot be deactivated and user does not force the operation", 
    ErrorCode = , ErrorType = typeof(InvalidOperationException))]
public void Remove(
    Guid featureId,
    bool force
)

Parameters

  • featureId
    Type: System.Guid

    The ID of the Feature to remove.

  • force
    Type: System.Boolean

    true to force the operation and ignore errors; otherwise, false.

Exceptions

Exception Condition
InvalidOperationException

The Feature is not activated.

ArgumentException

The error Feature was not found.

-or-

The Feature is not installed and the force operation is not specified.

Remarks

This method deactivates the specified Feature after it has removed it from the collection.

See Also

Reference

SPFeatureCollection Class

SPFeatureCollection Members

Remove Overload

Microsoft.SharePoint Namespace