Saturday, February 28, 2015

Use System Drawing dll from SQLCLR C code on SQL Server

I created a SQLCLR-Assembly that uses the System.Drawing Namespace. I was not able to deploy it from Visual Studio to the SQL Server because of the error message:

SQL72014: .Net SqlClient Data Provider: Meldung 6503, Ebene 16, Status 12, Zeile 1 Die system.drawing, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.-Assembly wurde im SQL-Katalog nicht gefunden.

How-i-fixed-it:

In SQL-Server Management Studio open up a new query:

ALTER DATABASE your_db_name
SET TRUSTWORTHY ON
GO
CREATE ASSEMBLY [System.Drawing]
FROM C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Drawing.dll
WITH PERMISSION_SET = UNSAFE
GO

Maybe you receive the following error:

Msg 33009, Level 16, State 2, Line 2
The database owner SID recorded in the master database differs from the database owner SID recorded in database XYZ. You should correct this situation by resetting the owner of database XYZ using the ALTER AUTHORIZATION Statement.

Here if found the solution: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81989

USE your_db_name
EXEC dbo.sp_changedbowner @loginame = Nsa, @map = false
GO
 
for details click below

No comments:

Post a Comment