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
[C#]
public virtual bool RegisterAssembly(
 Assembly assembly,
 AssemblyRegistrationFlags flags
);
[C++]
public: virtual bool RegisterAssembly(
 Assembly* assembly,
 AssemblyRegistrationFlags flags
);
[JScript]
public function RegisterAssembly(
   assembly : Assembly,
 flags : AssemblyRegistrationFlags
) : Boolean;

Parameters

assembly
The assembly to be registered.
flags
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.

Implements

IRegistrationServices.RegisterAssembly

Exceptions

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).

-or-

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

-or-

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

-or-

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

Remarks

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.

Example

The following entries are added to your registry.

HKEY_CLASSES_ROOT\progid
   (default) = progId
HKEY_CLASSES_ROOT\progid\CLSID
   (default) = clsid
HKEY_CLASSES_ROOT\CLSID\{clsid}
   (default) = progid
HKEY_CLASSES_ROOT\CLSID\{clsid}\InProcServer32
   (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}
HKEY_CLASSES_ROOT\CLSID\{clsid}\ProgId
   (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.

HKEY_CLASSES_ROOT\CLSID\{clsid}\InProcServer32
   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.

HKEY_CLASSES_ROOT\{clsid}\TypeLib
   (default) = tlbid
HKEY_CLASSES_ROOT\Typelib\{tlbid}\x.y\lcid\win32
   (default) = location of type library file
HKEY_CLASSES_ROOT\Typelib\{tlbid}\x.y\FLAGS
   (default) = 0

Where:

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=1.2.5.1.

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.

Requirements

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

Show: