.NET Framework Class Library
ComUnregisterFunctionAttribute Class

Specifies the method to call when you unregister an assembly for use from COM; this allows for the execution of user-written code during the unregistration process.

Inheritance Hierarchy

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)
<[%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_0_0_0%]([%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_0_0_1%].Method, Inherited := False)> _
<[%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_0_0_2%](True)> _
Public NotInheritable Class ComUnregisterFunctionAttribute _
	Inherits [%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_0_0_3%]
[[%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_1_0_0%]([%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_1_0_1%].Method, Inherited = false)]
public sealed class ComUnregisterFunctionAttribute : [%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_1_0_3%]
[[%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_2_0_0%]([%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_2_0_1%]::Method, Inherited = false)]
public ref class ComUnregisterFunctionAttribute sealed : public [%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_2_0_3%]
[<[%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_3_0_1%]([%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_3_0_2%].Method, Inherited = false)>]
type ComUnregisterFunctionAttribute =  
        inherit [%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_3_0_4%] 
public final class ComUnregisterFunctionAttribute extends [%$TOPIC/1a3h7ke6_en-us_VS_110_2_0_4_0_0%]

The ComUnregisterFunctionAttribute type exposes the following members.

Public method ComUnregisterFunctionAttributeInitializes a new instance of the ComUnregisterFunctionAttribute class.
Public property TypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Public method EqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public method GetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Explicit Interface Implementations
Explicit interface implemetation Private method _AttributeGetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeGetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeGetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeInvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)

You can apply this attribute to methods.

ComUnregisterFunctionAttribute enables you to add code that reverses the operations performed by a registration method. If you apply the ComRegisterFunctionAttribute to provide a registration method, you must also provide an unregistration method to reverse the operations done in the registration method. You can have only one unregistration method for a class.

The common language runtime calls the method with this attribute when its containing assembly is unregistered (directly or indirectly) with the Regasm.exe (Assembly Registration Tool) or through the RegistrationServicesUnregisterAssembly API method. Methods with this attribute can have any visibility (public, private, and so on), but must be static and must take a single Type parameter for the Type to unregister.


The following example demonstrates applying ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute to methods with the appropriate signature.

Imports System
Imports System.Runtime.InteropServices

Public Class MyClassThatNeedsToRegister

    <ComRegisterFunctionAttribute()> Public Shared Sub _
      RegisterFunction(t As Type)
        'Insert code here. 
    End Sub

    <ComUnregisterFunctionAttribute()> Public Shared Sub _
      UnregisterFunction(t As Type)
        'Insert code here. 
    End Sub 
End Class
using System;
using System.Runtime.InteropServices;

public class MyClassThatNeedsToRegister
   public static void RegisterFunction(Type t)
      //Insert code here.

   public static void UnregisterFunction(Type t)
      //Insert code here.
using namespace System;
using namespace System::Runtime::InteropServices;
public ref class MyClassThatNeedsToRegister

   static void RegisterFunction( Type^ t )

      //Insert code here.

   static void UnregisterFunction( Type^ t )

      //Insert code here.

Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.