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

By Robbe Morris
ODBC Drivers for QuickBooks, Salesforce, SAP, MSCRM, SharePoint … Free Trial!

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.

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

Popularity  (297 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of EggHeadCafe.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP