Reference Class Library in Sql Server Clr Project

纵然是瞬间 提交于 2019-12-10 13:56:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3859296/reference-class-library-in-sql-server-clr-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!