参考类库在SQL Server的CLR项目 [英] Reference Class Library in Sql Server Clr Project

查看:137
本文介绍了参考类库在SQL Server的CLR项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想引用一个类库,从 Visual C#中的SQL CLR数据库项目,但我得到的错误

I am trying to reference a class library from a Visual C# SQL CLR Database Project but I get the error

一提到'类库'不能添加。 SQL Server的项目只能引用其他SQL Server的项目。

A reference to 'class library' could not be added. SQL Server projects can reference only other SQL Server projects.

有没有办法来添加引用,所以我不需要重复code在类库?

Is there a way to add the reference so I don't need to duplicate the code in that class library?

我目前的解决方案,只是增加了一些必需的类文件到SQL CLR数据库项目的链接到真正的文件。这样,code是在同一个地方,即使将建立在两个不同的地点。这似乎为我的目的。

My current solution, is just adding the few required class files to the SQL CLR Database Project as links to the real files. That way code is in one place, even though it will build in two different spots. It seems to work for my purposes.

推荐答案

此限制的存在是因为引用的程序集必须在服务器上注册的第一位。执行CREATE ASSEMBLY sql语句,我用这个来测试它:

This restriction exists because the referenced assembly must be registered on the server first. Execute the CREATE ASSEMBLY sql statement, I used this one to test it:

CREATE ASSEMBLY ClassLibrary5
FROM 'c:\projects\classlibrary5\bin\release\classlibrary5.dll' 

接下来,使用添加引用您的数据库项目,注册组件显示在SQL Server的标签。

Next, use Add Reference on your database project, the registered assembly shows up in SQL Server tab.

这篇关于参考类库在SQL Server的CLR项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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