无法在 SQL 中创建程序集

编程入门 行业动态 更新时间:2024-10-09 01:15:47
本文介绍了无法在 SQL 中创建程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经深入研究了 SQL clr 编程.不幸的是,我的第一次尝试遇到了麻烦.我的 C# 汇编代码就是这样:

I've already dived into SQL clr programming. Unfortunately my first attempt is troubled. My C# assembly code is just so:

enter code here public partial class FirstCLRRoutines { public static int GetCLRFrameworkMajorVersion() { return System.Environment.Version.Major; } }

SQL 代码是:

USE master GO CREATE ASSEMBLY [Chapter2.FirstCLRRoutine] FROM 'D:\projeler\SQL_CLR\SQL_CLR\bin\Debug\SQL_CLR.dll'

但我从 MSSMSE 收到此错误消息:

But I get this error message from MSSMSE:

消息 6218,级别 16,状态 3,第 1 行为程序集SQL_CLR"创建程序集失败,因为程序集SQL_CLR"验证失败.检查引用的程序集是否最新且受信任的(对于 external_access 或不安全的)执行数据库.CLR 验证器错误消息(如果有)将遵循此留言

Msg 6218, Level 16, State 3, Line 1 CREATE ASSEMBLY for assembly 'SQL_CLR' failed because assembly 'SQL_CLR' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message

推荐答案

我刚刚遇到了完全相同的问题.

I just encountered exactly the same problem.

这是一个旧页面,但首先,最重要的是,最后,DLL必须使用 .NET 2.0 构建.SqlServer 2005 是使用 2.0 构建的,因为这是编写时可用的最新版本.SqlServer 2008 可能也有同样的问题.

This is an old page, but first, formost and finally, the DLL must be built with .NET 2.0. SqlServer 2005 is built with 2.0, because that is the latest available when it was written. SqlServer 2008 might also have the same issue.

DLL 和 SqlServer 必须都引用相同的 .NET 框架版本.一旦我想通了这一点,我在 2.0 和 shazam 下创建了一个单独的项目!第一次工作完美.

The DLL and the SqlServer must both reference the same .NET framekwork version. Once I figured this out, I created a separate project under 2.0 and shazam! worked perfect first time.

要查看您的 sql server 使用的 版本:

To see what version of your sql server uses:

select * from sys.dm_clr_properties

更多推荐

无法在 SQL 中创建程序集

本文发布于:2023-11-13 11:22:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584225.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!