使用 .Net 3.5 程序集 SQL 2005 CLR?

发布于 2024-07-29 01:32:20 字数 856 浏览 5 评论 0原文

我有一个 CLR 存储过程,它引用在 VS 2008 中创建的使用 Linq 的程序集。 我们将此程序集称为“MyLib”。

我似乎无法将“MyLib”放入我的 SQL 2005 数据库中。 我执行以下操作:

CREATE ASSEMBLY [MyLib]
    FROM 'C:\MyLib\bin\Release\MyLib.dll'
WITH PERMISSION_SET = UNSAFE
GO

但我收到错误:

Assembly 'MyLib' references assembly 'system.core, version=3.5.0.0, 
culture=neutral, publickeytoken=b77a5c561934e089.', which is not present 
in the current database. SQL Server attempted to locate and automatically 
load the referenced assembly from the same location where referring assembly 
came from, but that operation has failed (reason: 2(error not found)). Please
load the referenced assembly into the current database and retry your request.

除了为每个程序集编写“CREATE ASSEMBLY”命令之外,是否有一种更简单的方法可以将所有 .Net 3.5 程序集放入 SQL 2005 CLR 中? 是否有一些“最佳实践”方法可以做到这一点?

I have a CLR stored procedure that references an assembly created in VS 2008 that uses Linq. Lets call this assembly 'MyLib'.

I can't seem to get 'MyLib' into my SQL 2005 database. I do the following:

CREATE ASSEMBLY [MyLib]
    FROM 'C:\MyLib\bin\Release\MyLib.dll'
WITH PERMISSION_SET = UNSAFE
GO

But I get the error:

Assembly 'MyLib' references assembly 'system.core, version=3.5.0.0, 
culture=neutral, publickeytoken=b77a5c561934e089.', which is not present 
in the current database. SQL Server attempted to locate and automatically 
load the referenced assembly from the same location where referring assembly 
came from, but that operation has failed (reason: 2(error not found)). Please
load the referenced assembly into the current database and retry your request.

Is there an easier way to get all of the .Net 3.5 assemblies into the SQL 2005 CLR, other than me writing out a 'CREATE ASSEMBLY' command for each one? Is there some "best practice" way of doing this?

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

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

发布评论

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

评论(2

归途 2024-08-05 01:32:20

Check out this thread. Basically you have to manually get the new assemblies to load, instead of them being loaded automatically from the global assembly cache.

(the CLR for version 2.0 and 3.5 is the same)

欲拥i 2024-08-05 01:32:20

SQL Server 2005 附带 v2.0.50727 CLR - 它还包括 LINQ。

您将无法在 SQL 2005 CLR 程序集中使用 LINQ - 您需要坚持使用原始的 .NET 2.0 程序集集。

唯一的可能性很小,就是在您的部署中包含所有相关的 3.5 系统程序集(即 System.Linq、System.Data.Linq) - 它们都基于 .NET 2.0 CLR,因此这是可能的 - 我个人可能不会费心去尝试,似乎工作太多,麻烦太多。

SQL Server 2008 R2 很可能会附带一个新的 CLR(只是我的猜测——据我所知,目前还没有正式的确认或公告)。

马克

SQL Server 2005 shipped with the v2.0.50727 CLR - which did NOT include LINQ just yet.

You won't be able to use LINQ in SQL 2005 CLR assemblies - you need to stick to the original set of .NET 2.0 assemblies.

The only slim chance there is would be to include all the relevant 3.5 system assemblies (i.e. System.Linq, System.Data.Linq) in your deployment - they're all based on the .NET 2.0 CLR so that might be possible - I personally probably wouldn't bother trying, seems like too much work and too much hassle.

SQL Server 2008 R2 will most likely ship with a new CLR included (just my guess - no official confirmation or announcement available just yet, AFAIK).

Marc

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