SQL Server administration and T-SQL development, Web Programming with ASP.NET and Javascript, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.




Win FREE BOOK
from Kodyaz





SQL Server 2005 Msg 6505 Could not find Type in assembly


If you can register a CLR (Common Language Runtime) assembly successfully but can not create an external stored procedure referencing the registered CLR assembly and getting the following SQL Server 2005 error message:

Msg 6505, Level 16, State 1, Procedure myProcedure, Line 2
Could not find Type 'myCLRMethods' in assembly 'myCLRAssembly'.

You can solve your problem by using the class name of your assembly in the format [NamespaceName.ClassName]

Sample: We can use master database

use master
go

Then create the assembly in SQL Server 2005

Create assembly myCLRAssembly
from 'C:\WhidbeyProjects\myCLRAssembly\myCLRAssembly\bin\myCLRAssembly.dll'




At this point if you browse the Sys.Assemblies table you can see the CLR Assebly record created in Sys.Assemblies table.

Select * from Sys.Assemblies

Now, you can create the External Stored Procedure by running the below sql script.

Create Procedure myProcedure
as External Name myCLRAssembly.myCLRMethods.GetLuckyOne

The above statement may cause the following SQL Server 2005 error message

Msg 6505, Level 16, State 1, Procedure myProcedure, Line 2
Could not find Type 'myCLRMethods' in assembly 'myCLRAssembly'.

If you modify the Create Procedure sql statement as shown below, you will succeed in creating the procedure

Create Procedure myProcedure
as External Name myCLRAssembly.[myCLRAssembly.myCLRMethods].GetLuckyOne

Then you can execute your procedure by running

Exec myProcedure












Copyright © 2004 - 2011 Eralper Yilmaz. All rights reserved.
Community Server, by Telligent Systems