Sql Server Clr 项目中的参考类库

发布于 2024-09-26 10:00:43 字数 296 浏览 0 评论 0原文

我试图从 Visual C# SQL CLR 数据库项目引用类库,但收到错误

无法添加对“类库”的引用。 SQL Server 项目只能引用其他 SQL Server 项目。

有没有办法添加引用,这样我就不需要在该类库中复制代码?

编辑-解决方案?

我当前的解决方案只是将一些必需的类文件添加到 SQL CLR 数据库项目作为实际文件的链接。这样,代码就位于一个位置,即使它将构建在两个不同的位置。它似乎适合我的目的。

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

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

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

EDIT - Solution?

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.

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

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

发布评论

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

评论(1

沩ん囻菔务 2024-10-03 10:00:43

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

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

接下来,在数据库项目上使用“添加引用”,注册的程序集将显示在 SQL Server 选项卡中。

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' 

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

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