Solved
method in assembly is not static
Posted on 2006-11-04
I am trying to use an assembly called from a function in SQL Server 2005,
Here is the assembly code:
Public Class Distance
Public Function getDistance(ByVal lat1 As Double, ByVal lon1 As Double, ByVal lat2 As Double, ByVal lon2 As Double) As Double
Dim theta As Double
Dim dist As Double
Dim distance As Double
theta = lon1 - lon2
dist = Math.Sin(CDbl(deg2rad(lat1))) * Math.Sin(CDbl(deg2rad(lat2))) + Math.Cos(CDbl(deg2rad(lat1))) * Math.Cos(CDbl(deg2rad(lat2))) * Math.Cos(CDbl(deg2rad(theta)))
dist = Math.Acos(dist)
dist = CDbl(rad2deg(dist))
distance = dist * 60 * 1.1515
Return distance
End Function
Private Function deg2rad(ByVal Deg As Double) As Double
Return CDbl(Deg * Math.PI / 180)
End Function
Private Function rad2deg(ByVal Rad As Double) As Double
Return CDbl(Rad * 180 / Math.PI)
End Function
End Class
Here is the code to register the assembly with sql server:
CREATE ASSEMBLY asmDistanceFunctions
FROM 'E:\web\clients\out2daylive\Bin\asmDistanceFunctions.dll'
WITH PERMISSION_SET = SAFE
GO
Here is the code for the function calling the assembly - THIS IS WHERE I GET AN ERROR!
CREATE FUNCTION dbo.clrComputeDistance
(
@lat1 as float,
@lon1 as float,
@lat2 as float,
@lon2 as float
)
RETURNS float
AS EXTERNAL NAME [asmDistanceFunctions].[asmDistanceFunctions.Distance].[getDistance]
GO
I get the following error:
Msg 6573, Level 16, State 1, Procedure clrComputeDistance, Line 1
Method, property or field 'getDistance' of class 'asmDistanceFunctions.Distance' in assembly 'asmDistanceFunctions' is not static.
How do I correct this?