大网数据广告活动
数据库与应用安全

Use extended or SP_OA stored procedure to load CLR

· 52CE 我爱测

Loading CLR by using extended stored procedures or sp_OA stored procedures is not supported.

Original product version:   SQL Server
Original KB number:   322884

Summary

SQL Server 2005 and later versions host Common Language Runtime (CLR) and support procedures, functions, triggers, types, and aggregates that are written in CLR languages. In these versions, you can't load CLR by using extended stored procedures or sp_OA stored procedures.

Original product version:   SQL Server
Original KB number:   322884

More information

The .NET Framework assembly System.Runtime.InteropServices provides a robust environment for invoking assemblies from unmanaged code. However, there are several technical discordances between the internal implementations of CLR and SQL Server.

Threading

To increase performance, the CLR implements Thread Local Storage.

Additionally, CLR uses only thread-based scheduling and doesn't support Fiber-mode scheduling. However, SQL Server can use Fiber-mode scheduling. To configure this property, run the sp_configure stored procedure by using the lightweight pooling option. For more information about this topic, see lightweight pooling Server Configuration Option.

Memory

The use of extended stored procedures and OLE Automation both run in the virtual memory address space of the memory of SQL Server. The default SQL Server memory is only a fraction of the memory that SQL Server can potentially use and CLR competes with any existing implementations for these memory resources.

COM interoperability

This section specifically addresses the use of OLE Automation in SQL Server and it applies to both in-process and out-of-process COM objects. Assembly metadata for function interfaces implements a typed mechanism for any invocations.

As part of this design, the COM Callable wrapper for an assembly must use an external mechanism of mapping a ClassID to a member of a managed class. Because of this explicit mapping, there is no ability from an unmanaged perspective to establish a root list of available interfaces.

The extended stored procedure sp_oaCreate uses the IUnknown::QueryInterface interface to determine the object's support for a particular interface. The interoperability between CLR and unmanaged code relies on the IDispatch interface for implementing interfaces. Because there is no equivalent to a QueryInterface method in a CLR-based assembly, you can't create an instance of the object.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 09/25/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。