将 CLR 扩展集成到 SQL Server 时如何引用 GAC 程序集

发布于 2024-08-22 12:01:09 字数 296 浏览 3 评论 0原文

我在 SQL Server 2008 中创建了一个用于 CLR 集成的程序集。它有一个对 System.Web.Extensions 的引用,这是一个问题,因为当我尝试添加程序集时,出现以下错误:

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

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

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, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35.' was not found in the SQL catalog. (Microsoft SQL Server, Error: 6503)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-08-29 12:01:09

显然我不能,根据 this在 Microsoft 论坛上发帖

SQL Server 2005 中的 CLR 集成仅支持在 SQL Server 内部引用和使用 .NET 框架库的子集。这些是:

  • 自定义编组器
  • Microsoft.VisualBasic
  • 微软.VisualC
  • mscorlib
  • 系统
  • 系统.配置
  • 系统数据
  • 系统.Data.OracleClient
  • System.Data.SqlXml
  • 系统.部署
  • 系统.安全性
  • 系统.事务
  • 系统.Web.服务
  • 系统.Xml

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

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

例如:

从“C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll”创建程序集 SystemWeb

使用permission_set =不安全

由于所有依赖程序集都在同一目录中,SQL Server 会自动注册它们。

谢谢

-维尼特。

Apparently I can't, according to this post on the microsoft forums:

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
  • System.Configuration
  • System.Data
  • System.Data.OracleClient
  • System.Data.SqlXml
  • System.Deployment
  • System.Security
  • System.Transactions
  • System.Web.Services
  • System.Xml

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.

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\)

e.g:

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

with permission_set = unsafe

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

Thanks,

-Vineet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文