I am trying to load Aspose.Pdf in the SQL CLR along (with dependencies) with a custom DLL I made that will extract text from a PDF’s binary in a database. I have to load the following DLL’s in order to make this work:
CREATE ASSEMBLY [System.Drawing]
FROM ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Drawing.dll’
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY [System.Web]
FROM ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.web.dll’
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY [PresentationCore]
FROM ‘C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\PresentationCore.dll’
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY [Aspose.Pdf]
FROM ‘D:\Src\CISNET\Utilities\CisDocumentTextExtractor\Aspose.Pdf.dll’
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY TextExtractor
from ‘D:\Src\CISNET\Utilities\CisDocumentTextExtractor\bin\Debug\CisDocumentTextExtractor.dll’
WITH PERMISSION_SET = unSAFE
go
There is a scalar valued function that uses TextExtractor:
CREATE function ExtractText (@id varbinary(max))
RETURNS NVARCHAR(max) WITH EXECUTE AS CALLER, RETURNS NULL ON NULL INPUT
AS
EXTERNAL NAME TextExtractor.Narrative.ExtractText
This is where Aspose is used to extract the text from a PDF.
If I run the code in CisDocumentTextExtractor.dll in Visual Studio, everything works fine. However, when I use things in SQL, it does not work. I only get an error of:
Error:Could not load file or assembly ‘zx_26ad550982d54ff2ad2356552e708440, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.
That assembly is Aspos.Pdf 19.6. It looks like Apsose.Pdf cannot load due to one of the dependencies it needs but I am not sure.
The PDF stored in the DB are in their binary format so I simply pass the binary column to the function that uses the DLL.
This is occurring on multiple SQL versions so far, 2014 and 2017. I can try to create a solution if you cannot reproduce this.