I would like to investigate performance and difficulties related to generating
pdf files using a .Net CLR procedure.
Assume a situation where you have all data needed for pdf inside the db, it could be interesting
to generate pdf inside db without having to use seperate (SSRS) server.
For a situation like this I was tempted to use itextsharp.dll from
http://sourceforge.net/projects/itextsharp/files/latest/download
But the first obstacles already arises before I try to write my CLR proc when trying to load the
DLL into db:
1.) Using SSMS, right clicking "Assemblies" to get the "New Assembly"-GUI, typing in the path to assembly and choosing "Permission set"=Unrestricted
I got:
TITLE: Microsoft SQL Server Management Studio
Createfailed forSqlAssembly 'itextsharp'. (Microsoft.SqlServer.Smo)
For help,click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.3000.0+((SQL11_PCU_Main).121019-1322+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+SqlAssembly&LinkId=20476
ADDITIONAL INFORMATION:
An exceptionoccurredwhileexecuting aTransact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Assembly 'system.drawing,
version=2.0.0.0, culture=neutral,publickeytoken=b03f5f7f11d50a3a.'was notfound in the SQLcatalog. (Microsoft SQL Server,Error: 6503)
For help,click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=6503&LinkId=20476
2.) I also tried in SSMS:
CREATE ASSEMBLY itextsharp
FROM 'C:\...\PDFGenerator\PDFGenerator\bin\Debug\itextsharp.dll'
WITH PERMISSION_SET = UNSAFE;
Msg 10301, Level 16, State 1, Line 1
Assembly 'itextsharp' 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(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
======
Seems the 2. approach results in more informative error message;
but it says "Please load the referenced assembly...", isn't that what I actually have tried?
Is it suggestiong to do what I have tried to do??
I also tried this, but it didn't help either:
execute sp_configure 'show advanced options', 1;
GO
RECONFIGURE
go
execute sp_configure 'clr enabled', 1;
GO
RECONFIGURE
go
alter database bdj SET TRUSTWORTHY ON;
use master;
CREATE ASYMMETRIC KEY asymmetrickey1 FROM EXECUTABLE FILE = 'C:\...PDFgenerator\PDFGenerator\PDFGenerator\bin\Debug\itextsharp.dll' ;
CREATE LOGIN CLRLogin FROM ASYMMETRIC KEY asymmetrickey1;
GRANT UNSAFE ASSEMBLY TO CLRLogin --GRANT EXTERNAL ACCESS ASSEMBLY TO SQLCLRTestLogin
use bdj;
CREATE ASSEMBLY itextsharp
FROM 'C:\...\PDFgenerator\PDFGenerator\PDFGenerator\bin\Debug\itextsharp.dll'
WITH PERMISSION_SET = UNSAFE;
Any suggestions on how to solve this?
B. D. Jensen