0

I have problem with adding assembly dll in SQL Server 2014. I try to create assemble stored procedure like this

CREATE ASSEMBLY pdf_create FROM 'dll path\test.dll' WITH PERMISSION_SET = SAFE

SQL Server returns this error:

Assembly 'test' references assembly 'system.drawing, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(Не удается найти указанный файл.)). Please load the referenced assembly into the current database and retry your request.

Help please if you have any ideas

6
  • test.dll depends on system.drawing. You need to add system.drawing to SQL Server before adding test.dll. Commented Oct 15, 2018 at 10:35
  • 1
    Possible duplicate of SQL Server CLR integration with 3rd party SDK: Error on missing assembly System.Drawing Commented Oct 15, 2018 at 10:37
  • Why do you have a dependency on System.Drawing in the first place? Even if you manage to load it, it can easily leak GDI+ objects. That dll is meant to draw images on Windows Forms applications, not for server-side image processing. It was never meant for multi-threaded applications. Web projects use ImageSharp instead Commented Oct 16, 2018 at 12:03
  • @PanagiotisKanavos Sometimes one has no choice. E.g. we had to import System.Drawing because the .NET port of the ZXing library depends on it, and we use that to generate barcodes on the server side, and we have to do it on the server side because Crystal Reports would either ignore an image field not coming from a database, or crash upon trying to display it (and due to other reasons, we are stuck with a certain not very new version of Crystal Reports). Commented Oct 16, 2018 at 14:17
  • @GSerg web sites have the same problem and they don't use System.Drawing. Besides, you don't need ZXing or System.Drawing to generate barcodes, at least the common EAN13. You can use a barcode font to display a number as a barcode Commented Oct 16, 2018 at 15:08

1 Answer 1

1

So the question is why you would need a dependency on system.drawing.dll in an SQLCLR assembly? I would look at the code for the test.dll, and try to get rid of that particular dependency.

What you can do, if you absolutely need to include system.drawing.dll, is to copy it and put it in the same directory as the dll you try to create the assembly from, as SQL Server automatically creates assemblies from dependent assemblies if they are in the same path.

However, if you do that, then you probably need to change the permission set for the assembly you create as (if I remember correctly) system.drawing.dll needs a lesser permission set than SAFE.

So all in all, try to get rid of the dependency, you save yourself a lot of trouble that way.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.