使用SQLCLR了错误版本的.NET Framework错误、版本、SQLCLR、NET

2023-09-02 11:51:53 作者:ゅ  暖眸.

在最近我们开发服务器的重启 SQL服务器开始使用 .NET 4.0 的SQLCLR。这意味着,任何使用CLR在SQL工作,或者至少这是我的理解,通过阅读这些来源:

During a recent restart of our development server the SQL Server started using .NET 4.0 for the SQLCLR. This means that nothing using the CLR in SQL works, or at least that's my understanding by reading these sources:

http://software.intel.com/en-us/blogs/2009/10/16/sql-server-2008-sqlclr-net-framework-version/

www.sqlskills.com/博客/ BOBB /后/开-SQL-Server的和-NET-40.aspx

我们所得到的是这种类型的错误信息:

All we get are error messages of this type:

消息6517,级别16,状态1,行1未能创建应用程序域   xxx.dbo [DDL] 0.3。方法的类型签名不是互操作兼容。

Msg 6517, Level 16, State 1, Line 1 Failed to create AppDomain "xxx.dbo[ddl].3". Method's type signature is not Interop compatible.

运行语句(所建议的@约翰 - 克里斯滕森)

Running the statement (as suggested by @john-christensen)

select * from sys.dm_clr_properties

结果如下信息:

results in the following information:

*Name*      *Value*
directory   C:WindowsMicrosoft.NETFramework64v4.0.30319
version     v4.0.30319
state       CLR is initialized

有谁知道如何解决这个问题,否则我们怎么可以强制SQL Server的CLR使用该框架的早期版本?

Does anyone know how to solve this or how we can force SQL Server CLR to use an earlier version of the Framework?

推荐答案

通常情况下,你可以强制.NET应用程序通过指定使用特定的.NET Framework版本的 supportedRuntime 标签在应用程序的配置文件。

Typically you can force a .NET application to use a specific .NET Framework version by specifying the supportedRuntime tag in the application's config file.

所以,你可以尝试创建一个 sqlservr.exe.config 中的根路径下的 BINN 文件夹SQL实例,并指定有你想只使用.NET版本高达3.5。检查这个MSDN链接,在配置文件的结构。

So you could try creating a sqlservr.exe.config in the Binn folder under the root path of the SQL instance and specify there that you would like to use only .NET versions up to 3.5. Check this MSDN link for the structure of the config file.