• To consume a managed type from COM 之一 Register assemblies with COM


    Registering Assemblies with COM
    .NET Framework Developer's Guide
    Registering Assemblies with COM

    You can run a command-line tool called the Assembly Registration Tool (Regasm.exe) to register or unregister an assembly for use with COM. Regasm.exe adds information about the class to the system registry so COM clients can use the .NET class transparently. The RegistrationServices class provides the equivalent functionality.

    A managed component must be registered in the Windows registry before it can be activated from a COM client. The following table shows the keys that Regasm.exe typically adds to the Windows registry. (000...000 indicates the actual GUID value.)

    GUID Description Registry key
    CLSID Class identifier HKEY_CLASSES_ROOT\CLSID\{000...000}
    IID Interface identifier HKEY_CLASSES_ROOT\Interface\{000...000}
    LIBID Library identifier HKEY_CLASSES_ROOT\TypeLib\{000...000}
    ProgID Programmatic identifier HKEY_CLASSES_ROOT\000...000

    Under the HKCR\CLSID\{0000...0000} key, the default value is set to the ProgID of the class, and two new named values, Class and Assembly, are added. The runtime reads the Assembly value from the registry and passes it on to the runtime assembly resolver. The assembly resolver attempts to locate the assembly, based on assembly information such as the name and version number. For the assembly resolver to locate an assembly, the assembly has to be in one of the following locations:

    • The global assembly cache (must be a strong-named assembly).
    • In the application directory. Assemblies loaded from the application path are only accessible from that application.
    • Along an file path specified with the /codebase option to Regasm.exe.

    Regasm.exe also creates the InProcServer32 key under the HKCR\CLSID\{0000...0000} key. The default value for the key is set to the name of the DLL that initializes the common language runtime (Mscoree.dll).

    Examining Registry Entries

    COM interop provides a standard class factory implementation to create an instance of any .NET Framework class. Clients can call DllGetClassObject on the managed DLL to get a class factory and create objects, just as they would with any other COM component.

    A reference to Mscoree.dll appears in place of a traditional COM type library to indicate that the common language runtime creates the managed object.

  • 相关阅读:
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Ubuntu更换python默认版本
    Ubuntu pip版本的安装,卸载,查看,更新
    android底部导航栏小结
    jdk核心库中使用到的设计模式
    行为型-责任链模式(Chain of Responsibility)
    行为型-访问者模式(Visitor)
    结构型-迭代器模式(Adapter)
    行为型-观察者模式(Observer)
    设计模式-模式目录
  • 原文地址:https://www.cnblogs.com/MayGarden/p/1633948.html
Copyright © 2020-2023  润新知