Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Removes all the rules in an assembly from the SharePoint Health Analyzer rules list for the local farm.
Namespace: Microsoft.SharePoint.Administration.Health
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Shared Function UnregisterRules ( _
assembly As Assembly _
) As IDictionary(Of Type, Exception)
'Usage
Dim assembly As [Assembly]
Dim returnValue As IDictionary(Of Type, Exception)
returnValue = SPHealthAnalyzer.UnregisterRules(assembly)
public static IDictionary<Type, Exception> UnregisterRules(
Assembly assembly
)
Parameters
assembly
Type: System.Reflection.AssemblyAn assembly that contains rules to delete. SharePoint Health Analyzer rules are classes derived from the SPHealthAnalysisRule class.
Return value
Type: System.Collections.Generic.IDictionary<Type, Exception>
A list of types that could not be removed and the exceptions that were thrown when unregistration was attempted.
Examples
The following example shows how to call the UnregisterRules method in the FeatureDeactivating method of a class derived from the SPFeatureReceiver class. The example assumes that the feature receiver is in the same assembly as the rules that are being unregistered.
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
Assembly a = Assembly.GetExecutingAssembly();
IDictionary<Type, Exception> exceptions = SPHealthAnalyzer.UnregisterRules(a);
if (exceptions != null)
{
string logEntry = a.FullName;
if (exceptions.Count == 0)
{
logEntry += " All rules were unregistered.";
}
else
{
foreach (KeyValuePair<Type, Exception> pair in exceptions)
{
logEntry += string.Format(" Unregistration failed for type {0}. {1}",
pair.Key, pair.Value.Message);
}
}
System.Diagnostics.Trace.WriteLine(logEntry);
}
}
Public Overrides Sub FeatureDeactivating(ByVal properties As Microsoft.SharePoint.SPFeatureReceiverProperties)
Dim a As Assembly = Assembly.GetExecutingAssembly()
Dim exceptions As IDictionary(Of Type, Exception) = SPHealthAnalyzer.UnregisterRules(a)
If Not exceptions Is Nothing Then
Dim logEntry As String = a.FullName
If exceptions.Count = 0 Then
logEntry += " All rules were unregistered."
Else
Dim pair As KeyValuePair(Of Type, Exception)
For Each pair In exceptions
logEntry += String.Format(" Unregistration failed for type {0}. {1}", _
pair.Key, pair.Value.Message)
Next
End If
System.Diagnostics.Trace.WriteLine(logEntry)
End If
End Sub