代码之家  ›  专栏  ›  技术社区  ›  Paul Sainsbury

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

  •  5
  • Paul Sainsbury  · 技术社区  · 17 年前

    我有一个clr存储过程,它引用了在VS2008中创建的使用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.
    

    除了为每个.NET 3.5程序集编写一个“create assembly”命令外,是否有一种更简单的方法可以将所有.NET 3.5程序集都导入到SQL 2005 CLR中?有没有一些“最佳实践”的方法?

    2 回复  |  直到 17 年前
        1
  •  2
  •   Thorarin    17 年前

    退房 this thread . 基本上,您必须手动获取要加载的新程序集,而不是从全局程序集缓存自动加载它们。

    (2.0版和3.5版的clr相同)

        2
  •  1
  •   marc_s MisterSmith    17 年前

    随2.0.50727 clr一起提供的SQL Server 2005-它确实提供了 不是 包括Linq。

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

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

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

    马克

    推荐文章