How to run a DLL-based COM object outside the SQL Server process (198891)
The information in this article applies to:
- Microsoft SQL Server 6.5
- Microsoft SQL Server 7.0
- Microsoft SQL Server 2000 (all editions)
- Microsoft SQL Server 2005 Standard Edition
- Microsoft SQL Server 2005 Developer Edition
- Microsoft SQL Server 2005 Enterprise Edition
- Microsoft SQL Server 2005 Express Edition
- Microsoft SQL Server 2005 Workgroup
This article was previously published under Q198891 SUMMARY
Microsoft SQL Server 6.5 or later provides the capability to load and run custom Component Object Model (COM) objects through a set of OLE Automation stored procedures or through extended stored procedures. By default, DLL-based COM objects are loaded as in process server, which means that the COM objects are not only loaded within the SQL Server process memory address space, but they also have full access to this memory address space. Therefore, a COM object loaded in the SQL Server process space must adhere to the same rules as any DLL file. There is a potential that a COM object could overwrite memory within the SQL Server process or leak resources, causing instability.
If there is suspicion that a COM object may be affecting the robustness of the SQL Server process, you may want to use the steps in this article to instantiate the COM object outside the SQL Server process space. Implementation of the Distributed Component Object Model's (DCOM) specification of "Location Transparency" into the operating system has provided the ability to run a DLL-based COM object outside the SQL Server process space.
The process of running a DLL-based COM object outside of the address space of the main application is called remoting. Remoting requires that another executable be a surrogate process in place of the SQL Server executable. The default executable used by the DCOM Service Control Manager (Rpcss.exe) is named Dllhost.exe. The DCOM support structure uses the Dllhost.exe file to load the DLL into its process space and then uses proxy/stub pairs to marshal the requested interface transparently back to the client, which in this case is the SQL Server. This executable can accept multiple interface/method requests concurrently. After the interface use is complete, the DCOM Service Control Manager (SCM) manages the clean up and unloading of the Dllhost.exe file. COM objects should not be expected to retain state information in between instantiations.
In order for this article to work correctly, the system must be running a DCOM enabled operating system. This would be either Microsoft Windows NT 4.0 Service Pack 2 or later, Microsoft Windows 98 or Microsoft Windows 95 with the DCOM add-in installed. The following steps can apply to any DLL-based COM object that is being created in the SQL Server process space, whether it is being instantiated through sp_OACreate or an extended stored procedure.
REFERENCES
For more information about the SQL Server 6.5 COM Object model, click the following article number to view the article in the Microsoft Knowledge Base:
194661
SQL Server COM object persistence model
For more information about the way that the Sp_OA stored procedure is implemented, click the following article number to view the article in the Microsoft Knowledge Base:
180780
How Sp_OA procedures extension to SQL Server is implemented
For more information about running DLL-based COM objects within DLL Surrogates; please refer to the following:
Eddon, Guy; Eddon Henry, Inside Distributed Com (Mps). Microsoft Press, 1998, (ISBN 1-57231-849-X), Chapter Eight: 'DLL Surrogates and Executable Components'
Box, Don, Essential COM. Addison-Wesley Pub. Co., (ISBN 0-201-63446-5) Chapter Six: 'Applications'
Grimes, Richard, Professional DCOM Programming. Wrox Press Inc. (ISBN 1-861000-60-X), Chapter Four: 'Distributed Component Object Model'
The DCOM Add-In for Windows 95 is shipped with the SQL Server 7.0
media and the file is named Dcom95.exe. You can download Dcom95.exe from the following Web site:
Modification Type: | Major | Last Reviewed: | 5/30/2006 |
---|
Keywords: | kbinfo KB198891 |
---|
|