Reputation: 23901
I am trying to create a stored procedure using the .NET CLR. I successfully compiled the following code into a .NET 3.5 DLL.
Imports System.Math
Imports System.Text.RegularExpressions
Imports Microsoft.SqlServer.Server
Partial Public Class LevenshteinerAndSoundexer
<SqlProcedure()> _
Public Shared Function getLevenshteinDistance(ByVal string1 As String, ByVal String2 As String) As Integer
I then successfully added it as an assembly using this code:
create assembly
LevenshteinLibrary
from 'Path\LevenshteinLibrary.dll'
But when I got to create the procedure with this code
create procedure testCLR(@s1 nvarchar(1000), @s2 nvarchar(1000))
as external NAME LevenshteinLibrary.LevenshteinerAndSoundexer.getLevenshteinDistance
I get the error
"Could not find Type 'LevenshteinLibrary' in assembly 'LevenshteinLibrary'"
Why can't it "see" thefunction?
Here is what happens when I examine the DLL in ILSpy:
Here is what it looks like when I expand out the library
Upvotes: 3
Views: 2733
Reputation: 127583
According to the image you uploader your class LevenshteinerAndSoundexer
is under the namespace LevenshteinLibrary
. Therefor you need to include the namespace of the class (inside square brackets so it does not confuse the parser) when defining which class to use:
create procedure testCLR(@s1 nvarchar(1000), @s2 nvarchar(1000))
as external NAME LevenshteinLibrary.[LevenshteinLibrary.LevenshteinerAndSoundexer].getLevenshteinDistance
-- Name of object in SQL --^ ^ Name of function in class --^
-- Full name of class (including namespace)-/
Upvotes: 3