[英]Create CLR stored procedure using the dll created by .net framework 4.0 in sql server 2008. Is shows error
I am using the below code for CLR stored procedure creation. 我正在使用以下代码创建CLR存储过程。 While I am creating the assembly. 我正在创建程序集。 it shows the below issue. 它显示了以下问题。 My target framework is 4.0. 我的目标框架是4.0。 sql server is 2008 r2 sql server是2008 r2
SQL code: SQL代码:
create assembly SampleSearch from 'E:\CLR Files\Sample\ElasticSearch.dll'
error message: 错误信息:
CREATE ASSEMBLY for assembly 'ElasticSearch' failed because the assembly is built for an unsupported version of the Common Language Runtime. 程序集“ElasticSearch”的CREATE ASSEMBLY失败,因为程序集是为不支持的公共语言运行时版本构建的。
Microsoft SQL Server does not allow for mixed-mode CLR. Microsoft SQL Server不允许混合模式CLR。 Meaning, it is statically linked to a particular version of the CLR (which is not the same thing as the .NET Framework that most people confuse it for). 这意味着,它静态链接到特定版本的CLR(这与.NET Framework不同,大多数人都把它混淆了)。 SQL Server 2005, 2008, and 2008 R2 are linked to CLR version 2.0 which handles .NET Framework versions 2.0, 3.0, and 3.5, while SQL Server 2012 and 2014 are linked to CLR version 4.0 which handles .NET Framework versions 4.0, 4.5.x, 4.6.x, etc. SQL Server 2005,2008和2008 R2链接到处理.NET Framework版本2.0,3.0和3.5的CLR 2.0版,而SQL Server 2012和2014链接到处理.NET Framework 4.0,4.5的CLR 4.0版。 x,4.6.x等
You can either: 你可以:
UNSAFE
, and doing that requires setting the database option for TRUSTWORTHY
to ON
(which is best left as OFF
if at all possible). 如果您需要将.NET Framework 3.0或3.5用于不在2.0中的功能(而不是在受支持的.NET Framework库列表中),那么您还需要在SQL中注册相应的.NET Framework 3.0 / 3.5 DLL服务器作为UNSAFE
,这样做需要将TRUSTWORTHY
的数据库选项设置为ON
(如果可能的话,最好保留为OFF
)。 For more detailed info on the topic of .NET nuances within SQL Server (ie SQLCLR), please see the following article that I wrote on SQL Server Central, if not the entire series: 有关SQL Server中的.NET细微差别(即SQLCLR)主题的更多详细信息,请参阅我在SQL Server Central上编写的以下文章,如果不是整个系列:
Stairway to SQLCLR Level 5: Development (Using .NET within SQL Server) (free registration is required by that site) SQLCLR的阶梯级别5:开发(在SQL Server中使用.NET) (该站点需要免费注册)
The bad news is you can't do that. 坏消息是你无法做到这一点。 SQL 2008 supports V2.0 SQL 2008支持V2.0
将目标框架设置为2.0,然后再试一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.