How to call Unmanaged Code from SQL CLR.
-
I have written a C# dll which makes a call to some unmanaged code. When i tried to register this dll on SQL server 2005 i got the following error. Msg 6215, Level 16, State 1, Line 1 CREATE ASSEMBLY failed because method 'AddNumbers' on type 'Project1._Class1' in safe assembly 'Interop.Project1' has invalid attribute 0x1003. How do i register such a dll.
-
I have written a C# dll which makes a call to some unmanaged code. When i tried to register this dll on SQL server 2005 i got the following error. Msg 6215, Level 16, State 1, Line 1 CREATE ASSEMBLY failed because method 'AddNumbers' on type 'Project1._Class1' in safe assembly 'Interop.Project1' has invalid attribute 0x1003. How do i register such a dll.
You need to register the assembly as unsafe (project properties) and you'll need to configure SQL Server to allow unsafe assemblies (database must be marked as TRUSTWORTHY and you must have UNSAFE ASSEMBLY permissions). Everything you need to know should be in this article: http://www.codeproject.com/KB/database/SQLCLRIntegrationSecurity.aspx[^]
Mark's blog: developMENTALmadness.blogspot.com