简体   繁体   English

如何说服sql server 2008r2使用clr v4.0而不是v2.0?

[英]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?

So, the answer is - where is no way to do it. 所以,答案是 - 哪里无法做到。

In my case I lowed the target framework to 3.5 and excluded some clr functions. 在我的情况下,我将目标框架降低到3.5并排除了一些clr函数。

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.

相关问题 SSCLI(转子)为v4.0 clr? - SSCLI (Rotor) for the v4.0 clr? 调试时,托管旧版(v3.5,v3.0,v2.0)和托管旧版(v4.5,v4.0)的默认设置在哪里? - Where is the default setting for Managed Legacy (v3.5, v3.0, v2.0) vs Managed Legacy (v4.5, v4.0) when debugging? 从源文件编译程序时,如何将目标框架设置为v2.0或v3.5而不是4.0? - How to set the target framework to v2.0 or v3.5 instead of 4.0 when compiling a program from a source file? 从.Net v4.0程序集链接到.Net v2.0程序集也似乎链接(和别名)mscorlib v2.0。 为什么? - Linking to a .Net v2.0 assembly from a .Net v4.0 assembly also appears to link (and alias) mscorlib v2.0. Why? OData v4.0 - 如何使用$ crossjoin的支持? - OData v4.0 - How can I use the support for $crossjoin? OData v4.0如何设置MaxExpansionDepth? - OData v4.0 How to set MaxExpansionDepth? 如何在没有.NET v4.0的目标环境上部署.NET v4.0应用程序? - How can I deploy .NET v4.0 application on target environment without .NET v4.0? 使用运行时4.0的v2.0目录中的程序集 - Assemblies in v2.0 directory which using runtime 4.0 如何在Windows 8中处理.Net Framework版本V4.0和V3.5 - How to deal with .Net framework versions V4.0 vs V3.5 in Windows 8 在SQL Server 2008R2中引用签名程序集 - Referencing Signed Assembly in SQL Server 2008R2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM