src/Microsoft/Windows/ComponentObjectModel/_Library/ComponentRegistrationManager.cs
/// <summary>
/// Registers a COM component, implemented with the .NET Framework.
/// </summary>
/// <param name="componentRegistrationInformation">The COM component information.</param>
/// <param name="scope">The <see cref="ComponentRegistrationScope"/>.</param>
Registers a COM component, implemented with the .NET Framework.
Registers a COM component implemented with the . NET Framework .
public void Register( DotNetFrameworkComponentRegistrationInformation componentRegistrationInformation, ComponentRegistrationScope scope ) {
            RegistryHive hive = GetHiveForScopeOrThrow( scope );
            using( IRegistryKey hiveKey = _registry.OpenBaseKey( hive, RegistryView.Default ) ) {
                using( IRegistryKey classesClsidKey = hiveKey.OpenSubKey( @"Software\Classes\CLSID\", true ) ) {
                    using( IRegistryKey clsidKey = classesClsidKey.CreateSubKey( Utils.GuidToClsid( componentRegistrationInformation.CLSID ), true ) ) {
                        using( IRegistryKey serverKey = clsidKey.CreateSubKey( componentRegistrationInformation.ServerType.ToString(), true ) ) {
                            switch( componentRegistrationInformation.ServerType ) {
                                case ComponentServerType.InprocServer32: {
                                        serverKey.SetValue( "ThreadingModel", componentRegistrationInformation.ThreadingModel.ToString(), RegistryValueKind.String );
                                        serverKey.SetValue( "", componentRegistrationInformation.DotNetShimPath );
                                        break;
                                    }
                                case ComponentServerType.InprocServer:
                                case ComponentServerType.LocalServer:
                                case ComponentServerType.LocalServer32: {
                                        throw new NotImplementedException();
                                    }
                                default: {
                                        throw new ArgumentException();
                                    }
                            }
                            SetValues( serverKey, componentRegistrationInformation.SharedTypeInformation );
                            if( null == componentRegistrationInformation.VersionedTypeInformation || componentRegistrationInformation.VersionedTypeInformation.Count == 0 ) {
                                using( IRegistryKey versionedKey = serverKey.CreateSubKey( componentRegistrationInformation.SharedTypeInformation.AssemblyVersion ) ) {
                                    SetValues( versionedKey, componentRegistrationInformation.SharedTypeInformation );
                                }
                            }
                            else {
                                foreach( DotNetFrameworkComponentRegistrationTypeInformation entry in componentRegistrationInformation.VersionedTypeInformation ) {
                                    using( IRegistryKey versionedKey = serverKey.CreateSubKey( entry.AssemblyVersion ) ) {
                                        SetValues( versionedKey, entry );
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
public void Register ( DotNetFrameworkComponentRegistrationInformation componentRegistrationInformation , ComponentRegistrationScope scope ) { RegistryHive hive = GetHiveForScopeOrThrow ( scope ) ; using ( IRegistryKey hiveKey = _registry . OpenBaseKey ( hive , RegistryView . Default ) ) { using ( IRegistryKey classesClsidKey = hiveKey . OpenSubKey ( @"Software\Classes\CLSID\" , true ) ) { using ( IRegistryKey clsidKey = classesClsidKey . CreateSubKey ( Utils . GuidToClsid ( componentRegistrationInformation . CLSID ) , true ) ) { using ( IRegistryKey serverKey = clsidKey . CreateSubKey ( componentRegistrationInformation . ServerType . ToString ( ) , true ) ) { switch ( componentRegistrationInformation . ServerType ) { case ComponentServerType . InprocServer32 : { serverKey . SetValue ( " " , componentRegistrationInformation . ThreadingModel . ToString ( ) , RegistryValueKind . String ) ; serverKey . SetValue ( " " , componentRegistrationInformation . DotNetShimPath ) ; break ; } case ComponentServerType . InprocServer : case ComponentServerType . LocalServer : case ComponentServerType . LocalServer32 : { throw new NotImplementedException ( ) ; } default : { throw new ArgumentException ( ) ; } } SetValues ( serverKey , componentRegistrationInformation . SharedTypeInformation ) ; if ( null == componentRegistrationInformation . VersionedTypeInformation || componentRegistrationInformation . VersionedTypeInformation . Count == 0 ) { using ( IRegistryKey versionedKey = serverKey . CreateSubKey ( componentRegistrationInformation . SharedTypeInformation . AssemblyVersion ) ) { SetValues ( versionedKey , componentRegistrationInformation . SharedTypeInformation ) ; } } else { foreach ( DotNetFrameworkComponentRegistrationTypeInformation entry in componentRegistrationInformation . VersionedTypeInformation ) { using ( IRegistryKey versionedKey = serverKey . CreateSubKey ( entry . AssemblyVersion ) ) { SetValues ( versionedKey , entry ) ; } } } } } } } }
Registers a COM component, implemented with the .NET Framework.
Registers a COM component implemented with the . NET Framework .
// Write shared values // Write Version-Dependent subkeys and values // Case 1: Caller did not provide a list of version-dependent values // Case 2: Caller provided a list of version-dependent data
componentRegistrationInformation
DotNetFrameworkComponentRegistrationInformation
The COM component information.
The COM component information .
scope
ComponentRegistrationScope
None