This documentation is archived and is not being maintained.

RegistrationServices.RegisterAssembly Method

Registers the classes in a managed assembly to enable creation from COM.

[Visual Basic]
Public Overridable Function RegisterAssembly( _
   ByVal assembly As Assembly, _
   ByVal flags As AssemblyRegistrationFlags _
) As Boolean Implements IRegistrationServices.RegisterAssembly
public virtual bool RegisterAssembly(
 Assembly assembly,
 AssemblyRegistrationFlags flags
public: virtual bool RegisterAssembly(
 Assembly* assembly,
 AssemblyRegistrationFlags flags
public function RegisterAssembly(
   assembly : Assembly,
 flags : AssemblyRegistrationFlags
) : Boolean;


The assembly to be registered.
An AssemblyRegistrationFlags value indicating any special settings used when registering assembly.

Return Value

true if assembly contains types that were successfully registered; otherwise false if the assembly contains no eligible types.




Exception Type Condition
ArgumentNullException assembly is a null reference (Nothing in Visual Basic).
InvalidOperationException The full name of assembly is a null reference (Nothing in Visual Basic).


A method marked with ComRegisterFunctionAttribute is not static (Shared in Visual Basic) .


There is more than one method marked with ComRegisterFunctionAttribute at a given level of the hierarchy.


The signature of the method marked with ComRegisterFunctionAttribute is not valid.


RegisterAssembly adds the appropriate registry entries for the types in the specified assembly. This method also calls any registration functions found in the assembly.

Use Assembly.Load to get an assembly.


The following entries are added to your registry.

   (default) = progId
   (default) = clsid
   (default) = progid
   (default) = mscoree.dll
   Class = ClassName
   ThreadingModel = Both
   Assembly = Stringized_assembly_reference
   Codebase = path_of_private_assembly
   RuntimeVersion = version_of_the_runtime
HKEY_CLASSES_ROOT\CLSID\{clsid}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}
   (default) = progid

If the /codebase switch is used, the following additional entry is created in the registry. The assembly must be strong named when using the /codebase switch.

   Codebase = path_of_private_assembly

If the /tlb switch is used, a type library is generated and the following additional entries are created in the registry.

   (default) = tlbid
   (default) = location of type library file
   (default) = 0


progid is the programmatic identifier assigned to the class.

clsid is the guid assigned to the class.

tlbid is the guid that identifies the type library.

x.y is the major and minor versions of the type library.

lcid is the locale id of the type library.

The stringized_assembly_reference found under the InProcServer32 key is the string form of the name of the assembly containing the class. The string is obtained from AssemblyName.FullName and is used to locate and load the assembly when the class is being created. An example of a stringized assembly name is FunnyFarm.BarnYard.Mammal, Ver=

The path_of_private_assembly field should only be used for private assemblies that are not installed in the Global Assembly Cache. The path should be the full path, including the file name, where the assembly is located.

The version_of_the_runtime field identifies which version of the runtime to use when more than one runtime version is installed on a system.

The component category identified by the guid 62C8FE65-4EBB-45e7-B440-6E39B2CDBF29 identifies all .NET components.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

RegistrationServices Class | RegistrationServices Members | System.Runtime.InteropServices Namespace