[英]How to convince sql server 2008r2 to use clr v4.0 instead of v2.0?
I have sql server 2008r2. 我有sql server 2008r2。 According to my internet research it supports .net framework 4.0.
根据我的互联网研究,它支持.net framework 4.0。 I tried to install my assembly with sql clr functions and receved an error.
我试图用sql clr函数安装我的程序集并收到错误。
CREATE ASSEMBLY for assembly 'MyAssembly' failed because the assembly is built for an unsupported version of the Common Language Runtime.
程序集“MyAssembly”的CREATE ASSEMBLY失败,因为程序集是为不支持的公共语言运行时版本构建的。
Query 询问
select * from sys.dm_clr_properties
Gives result: 给出结果:
directory C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\
目录C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v2.0.50727 \\
version v2.0.50727
版本v2.0.50727
CLR is initialized
CLR已初始化
I check C:\\Windows\\Microsoft.NET\\Framework64\\ to be sure and found v4.0.30319 folder where. 我检查C:\\ Windows \\ Microsoft.NET \\ Framework64 \\以确定并找到v4.0.30319文件夹所在的位置。 So, .net v4.0 is installed.
所以,安装了.net v4.0。
So, I need to change CLR version that used for sql. 所以,我需要更改用于sql的CLR版本。 I tried
我试过了
sp_configure 'clr enabled', 0;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
It did not help. 它没有帮助。 I tried to add sqlservr.exe.config with content
我尝试添加带有内容的sqlservr.exe.config
<configuration>
<startup>
<requiredRuntime version="v4.0"/>
</startup>
</configuration>
to C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\Binn folder and restart sql server. 到C:\\ Program Files \\ Microsoft SQL Server \\ MSSQL10_50.MSSQLSERVER \\ MSSQL \\ Binn文件夹并重新启动sql server。 It didn't help as well.
它没有帮助。
I know about option with creating registry key HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft.NETFramework\\OnlyUseLatestCLR and setting it to 1. It can broke other solutions, so I affraid of using it on production. 我知道创建注册表项HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft.NETFramework \\ OnlyUseLatestCLR并将其设置为1的选项。它可以打破其他解决方案,所以我很害怕在生产中使用它。
Is where any suggestions how to convince sql server to use clr v4.0? 有什么建议如何说服sql server使用clr v4.0?
You can't. 你不能。 In an article posted by Doug Holland in 2010 it is explained that older versions of SQL Server (up to and including 2008 R2) use the LockClrVersion call to restrict the .NET version that can be loaded to the latest 2.0 version.
在Doug Holland于2010年发表的一篇文章中,解释了旧版本的SQL Server(包括2008 R2)使用LockClrVersion调用来限制可以加载到最新2.0版本的.NET版本。
To use .NET 4.0 you will have to use SQL Server 2012 and above 要使用.NET 4.0,您必须使用SQL Server 2012及更高版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.