Building and Registering a COM DLL

A registry file that describes your application, type library, and Automation objects must be merged into the Windows system registry to make the components in your DLL accessible. Additional steps are required to link a COM DLL and a separate ObjectARX application. These steps are described in the following sections:

To prepare a COM DLL that is separate from the ObjectARX application

  1. Build the COM DLL.
  2. If any decorated names representing your ObjectARX classes appear in linker errors as unresolved external symbols, add these names to the Exports section of the ObjectARX DEF file.
  3. If you changed your ObjectARX DEF file in step 2, rebuild the ObjectARX application.
  4. Edit the COM DLL project's properties.
  5. In the linker input dependency settings, add the library name for your ObjectARX application to the object/library modules list, after rxapi.lib. The following example is from the AsdkSquareWrapper sample project:
..\..\..\..\lib\rxapi.lib ..\square\ReleaseEnt\square.lib 
etc.

Save the project property settings and close the dialog box.

Build and register the COM DLL as described in the next procedure.

To build and register your component server

  1. Build the COM application.

    A message may appear, indicating that REGSRVR32 failed to load AutoCAD. To eliminate this message in the future, remove all custom build steps for registering a COM server from your COM project settings.

  2. Create a REG file for your application with GUIDs for the object and the type library that match those in the IDL file.

    The following example is the REG file for AsdkSquareWrapper:

REGEDIT
; This .REG file may be used by your SETUP program.
; If a SETUP program is not available, the entries below will be
; registered in your InitInstance automatically with a call to
; CWinApp::RegisterShellFileTypes and 
; COleObjectFactory::UpdateRegistryAll.
HKEY_CLASSES_ROOT\TypeLib\{800F70A1-6DE9-11D2-A7A6-0060B0872457}
HKEY_CLASSES_ROOT\TypeLib\{800F70A1-6DE9-11D2-A7A6-0060B0872457}
    \1.1 = AsdkSquareLib 1.0 Type Library
HKEY_CLASSES_ROOT\TypeLib\{800F70A1-6DE9-11D2-A7A6-0060B0872457}
    \1.1\0\win32=
    E:\TEMP\square\AsdkSquareLib\Debug\AsdkSquareLib.dll
HKEY_CLASSES_ROOT\TypeLib\{800F70A1-6DE9-11D2-A7A6-0060B0872457}
    \1.1\9\win32 =
    E:\TEMP\square\AsdkSquareLib\Debug\AsdkSquareLib.dll
HKEY_CLASSES_ROOT\CLSID\{800F70AE-6DE9-11D2-A7A6-0060B0872457} =
    AsdkSquareWrapper Class
HKEY_CLASSES_ROOT\CLSID\{800F70AE-6DE9-11D2-A7A6-0060B0872457}
    \InProcServer32 =
    E:\TEMP\square\AsdkSquareLib\Debug\AsdkSquareLib.dll
HKEY_CLASSES_ROOT\Interface\{800F70AD-6DE9-11D2-A7A6-0060B0872457}
    = IAsdkSquareWrapper Interface
HKEY_CLASSES_ROOT\Interface\{800F70AD-6DE9-11D2-A7A6-0060B0872457}
    \TypeLib = {E3D2C633-69C9-11D2-A7A2-0060B0872457}
HKEY_CLASSES_ROOT\Interface\{800F70AD-6DE9-11D2-A7A6-0060B0872457}
    \ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\ObjectDBX\R24.1\ActiveXCLSID
    \AsdkPoly = {800F70AE-6DE9-11D2-A7A6-0060B0872457}

See Creating a Registry File for more information on REG files.

Run the REG file from Explorer.

Note: Applications that rely on an external ObjectDBX or ObjectARX server DLL must ensure that the server is loaded properly in AutoCAD. Separate COM DLLs that support out-of-process environments, such as Visual Basic, usually delegate this responsibility to their client applications. However, combined COM DLLs that support only in-process AutoCAD clients may use ObjectARX APIs in the DllMain function to guarantee that the necessary server is loaded. The ObjectARX Wizard's COM server option provides this functionality.