无法在 SQL 中创建程序集 [英] Failed to CREATE AN ASSEMBLY in SQL

查看:28
本文介绍了无法在 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 是使用 .net 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 .net 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 使用的 .net 版本:

To see what version of .net your sql server uses:

select * from sys.dm_clr_properties

这篇关于无法在 SQL 中创建程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆