SQLCLR 使用错误版本的 .NET Framework

发布于 2024-08-31 17:23:48 字数 1007 浏览 5 评论 0原文

在我们的开发服务器最近重新启动期间,SQL Server 开始使用 .NET 4.0 作为 SQLCLR。这意味着在 SQL 中使用 CLR 不起作用,或者至少这是我通过阅读以下来源的理解:

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

www.sqlskills.com/BLOGS/BOBB/post/On-SQL-Server-and-NET-40.aspx

我们得到的只是这种类型的错误消息:

消息 6517,级别 16,状态 1,第 1 行无法创建 AppDomain “xxx.dbo[ddl].3”。方法的类型签名与互操作不兼容。

运行该语句(按照 @john-christensen 的建议)

select * from sys.dm_clr_properties

会产生以下信息:

*Name*      *Value*
directory   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
version     v4.0.30319
state       CLR is initialized

有谁知道如何解决这个问题或者我们如何强制 SQL Server CLR 使用早期版本的框架?

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/BLOGS/BOBB/post/On-SQL-Server-and-NET-40.aspx

All we get are error messages of this type:

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:\Windows\Microsoft.NET\Framework64\v4.0.30319\
version     v4.0.30319
state       CLR is initialized

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

一场春暖 2024-09-07 17:23:48

我遇到了同样烦人的问题。我的数据库中的地理/几何内容都不起作用。我重新安装了一些不成功的 SQL Server,最终(几周后!)发现注册表中的以下键已设置为“1”,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\\.NETFramework\OnlyUseLatestCLR

当我将其重置为“0”时,并重新启动计算机,一切又恢复正常了!

I experienced the same annoying problem. None of the Geography/Geometry stuff in my database worked. Took me some unsuccessful reinstalls of SQL server to finally (some weeks later!) find the following key in my registry had been set to '1'

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\\.NETFramework\OnlyUseLatestCLR

when I reset it to '0', and rebooted the machine, things worked again!

羁拥 2024-09-07 17:23:48

通常,您可以通过在应用程序的配置文件中指定 supportedRuntime 标记来强制 .NET 应用程序使用特定的 .NET Framework 版本。

因此,您可以尝试在 SQL 实例根路径下的 \Binn 文件夹中创建 sqlservr.exe.config 并在其中指定您只想使用 .NET版本最高 3.5。检查此 MSDN 链接了解配置文件的结构。

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.

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.

春风十里 2024-09-07 17:23:48

从这篇文章和我在网上的研究来看,看起来可能会发生相反的情况 - 您可能会注册 4.0 DLL 吗?看来 SQL Server 2008 将始终加载 2.0 CLR,而不是 4.0 CLR。尝试运行这个语句,它会告诉你你的 SQL 服务器正在运行什么版本:

select * from sys.dm_clr_properties

From the article and my research on the web, it looks like the opposite might be happening - could you potentially be registering a 4.0 DLL? It appears that SQL Server 2008 will always load the 2.0 CLR and not the 4.0 CLR. Try running this statement, it will tell you what version your SQL server is running:

select * from sys.dm_clr_properties
一身仙ぐ女味 2024-09-07 17:23:48

在您引用的英特尔帖子中,如果您仔细阅读,它会说:

SQL Server 2008 和即将推出的
SQL Server 2008 R2 版本,以前
代号为“乞力马扎罗”,将两者
继续加载最新服务
发布 2.0 CLR 版本

后来:

虽然 SQL Server 的未来版本
可能会加载更新版本的 CLR,或者
甚至支持多个加载
进程内的 CLR,版本 2.0
CLR 的一部分将保留给 SQLCLR
SQL Server 2008 和 SQL Server 中
2008 R2。

我不知道你是如何设法将 .NET 4 之类的东西加载到 SQL Server 2008 R2 中的......

In your post at Intel that you reference, if you read it closely, it says:

SQL Server 2008 and the forthcoming
SQL Server 2008 R2 release, previously
codenamed "Kilimanjaro", will both
continue to load the latest service
release of the version 2.0 CLR
.

And later on:

While future versions of SQL Server
may load newer versions of the CLR, or
even support the loading of multiple
CLR's within the process, version 2.0
of the CLR is here to stay for SQLCLR
within SQL Server 2008 and SQL Server
2008 R2.

I don't know how you manage to get something like .NET 4 loaded inside SQL Server 2008 R2....

老街孤人 2024-09-07 17:23:48

他们做出了明确的选择,以确保 .NET 4.0 的安装不会产生影响。它不应使用 .NET 4.0 或除新的填充文件 mscoree.dll 和 mscoreei.dll 之外的任何新文件。这些应该与 2.0 运行时向后兼容。您可以运行 Process Explorer 查看加载的 dll 的版本号,以验证它是否运行在正确的运行时。

They made explicit choices to ensure that installation of .NET 4.0 would be non-impactful. It shouldn't be using .NET 4.0 or any of the new files except for the new shim files, mscoree.dll and mscoreei.dll. Those should be backward compatible with the 2.0 runtime. You could run Process Explorer to see the version numbers of the dll's loaded to verify that it is running the right runtime.

野侃 2024-09-07 17:23:48

我遇到这个问题一天了,更新我的 Windows 和 .NET 框架后,问题消失了。该问题与 .Net 框架有关,请尝试修复它。

I had this problem for a day and after updating my windows and .NET frameworks problem disappeared.the problem relates to .Net framework try to repair it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文