SQL Server 2005 Msg 6505 - Could not find Type in Assembly

Printer Friendly Version


If you are trying to register CLR assembly for use in a SQL Server User-Defined Function and receive the 6505 error message about not being able to find the assembly, then Visual Studio .NET 2005 may be the culprit.

Let's review the code you've tried:

CREATE ASSEMBLY MyAssemblyName
FROM 'C:\TEMP\MyAssemblyName.dll'
WITH PERMISSION_SET = SAFE;

create function FindMatchingKeys
(
@pattern nvarchar(500),
@searchString nvarchar(2000)
)
returns table
(
ItemsFound int
) as
external name MyAssemblyName.MyClassName.MyMethodName

For some reason, you need to reference the assembly name
with the class as well:

external name MyAssemblyName.[MyAssemblyName.MyClassName].MyMethodName



Submission Date:  12/14/2005 10:03:32 AM
Submitted By:  Robbe Morris
My Home Page:  http://www.robbemorris.com

My Biography
Robbe has been a Microsoft MVP for C# since 2004. He is also the co-founder of EggHeadCafe. Robbe has extensive experience with web technologies, .NET, C#, CTI based applications, system administration, .NET Compact Framework, and data modeling. In his spare time, he blogs from time to time at http://robbemorris.blogspot.com