将CLR扩展集成到SQL Server中时如何引用GAC程序集 [英] How to reference GAC assemblies when integrating a CLR extension into SQL Server

查看:60
本文介绍了将CLR扩展集成到SQL Server中时如何引用GAC程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为SQL Server 2008中的CLR集成创建了一个程序集。它具有对 System.Web.Extensions 的引用,这是一个问题,因为当我尝试执行以下操作时,添加我的程序集,我得到以下错误:

I've created an assembly for CLR integration in SQL Server 2008. It has one reference to System.Web.Extensions, which is an issue because when I try to add my assembly, I get the following error:


Assembly'system.web.extensions,版本= 3.5.0.0,文化=中性,在SQL目录中找不到publickeytoken = 31bf3856ad364e35。 (Microsoft SQL Server,错误:6503)

Assembly 'system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35.' was not found in the SQL catalog. (Microsoft SQL Server, Error: 6503)

如何使SQL Server引用所需的程序集?

How do I get SQL Server to reference the required assembly?

推荐答案

显然,根据此帖子


SQL Server 2005中的> CLR集成仅支持.NET框架库的一个子集,以供在SQL Server中引用和使用。这些是:

CLR integration in SQL Server 2005 supports only a subset of .NET framework libraries to be references and used inside SQL Server. These are:


  • CustomMarshalers

  • Microsoft.VisualBasic

  • Microsoft.VisualC

  • mscorlib

  • 系统

  • System.Configuration

  • System.Data

  • System.Data.OracleClient

  • System.Data.SqlXml

  • 系统。部署

  • System.Security

  • System.Transactions

  • System.Web.Services

  • System.Xml

  • CustomMarshalers
  • Microsoft.VisualBasic
  • Microsoft.VisualC
  • mscorlib
  • System
  • System.Configuration
  • System.Data
  • System.Data.OracleClient
  • System.Data.SqlXml
  • System.Deployment
  • System.Security
  • System.Transactions
  • System.Web.Services
  • System.Xml

这些库已经过测试,以确保它们在SQL Server中可以可靠运行。这些库可以用任何代码引用,而不必使用CREATE ASSEMBLY注册。这些是SQL Server允许CLR从GAC加载的唯一程序集。所有其他程序集(在.NET框架内或其他方式)都需要在数据库内部显式注册。用户应该对这些库之外的任何代码进行可靠性和安全性的良好测试。

These libraries have been tested to ensure they are reliable to run inside SQL Server. These libraries can be referenced in any code and do not have to be registered using CREATE ASSEMBLY. These are the only assemblies that SQL Server allows CLR to load from GAC. All other assemblies (within .NET framework or otherwise) need to be registered explicitly inside the database. Any code that is outside of these libraries should be tested well by the user for reliability and security.

尽管您要注册的程序集不受CLR集成的支持,如果您可以很好地测试功能,则可以使用它们。注册system.web及其所有依赖项的一种简单方法是从.NET Framework安装目录(通常是c:\windows\microsoft.net\framework\)中注册它们。

While the assemblies you are trying to registered are not supported by CLR integration you can use them if you test your functionality well. An easy way to register system.web and all its dependencies is to register them from the .NET framework install directory (usually c:\windows\microsoft.net\framework\)

例如:

从 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System创建组件SystemWeb。 Web.dll'

CREATE ASSEMBLY SystemWeb from 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll'

具有权限设置=不安全

由于所有相关程序集都在同一目录中,因此SQL服务器会自动注册它们。

Since all the dependent assemblies are in the same directory, SQL Server would automatically register them.

谢谢

-Vineet。

这篇关于将CLR扩展集成到SQL Server中时如何引用GAC程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆