CLR integration

Sep 24, 2013 at 11:26 AM
Dear all,

I have a CLR stored procedure project where I need to create .xlsx spreadsheets.

Does anyone know how to register the EPPlus.dll assembly so it's accessible from a CLR stored procedure?

On the SQL box I've run:
    FROM '<filepath>\EPPlus.dll'
but this error message is shown:
Assembly 'EPPlus' references assembly 'windowsbase, version=, culture=neutral, publickeytoken=31bf3856ad364e35.', 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.
Where can I get "windowsbase" and what else do I need to do?


Oct 1, 2013 at 9:31 PM
I'm not sure specifically about that particular issue, but EPPlus may reference a number of BCL methods that aren't available within the CLR context running in SQL Server.

For more information, see this TechNet document:

There may also be a disconnect between the version of .NET that your EPPlus DLL is compiled to and the one available within your MSSQL instance. I don't recall offhand how to switch the version in MSSQL.

Finally, have you enabled CLR hosting within your SQL Server instance? There's a procedure to doing so, and until you do, you won't be able to load any .NET libraries.
Oct 7, 2013 at 7:55 AM
Thanks for getting back to me.

Yes I've run the "CLR Enabled" option but to no avail. We've decided to go down the Console/Service/Library polling route as the project needed starting ASAP.


Feb 24, 2014 at 9:25 PM
Edited Feb 24, 2014 at 9:25 PM
Hi Grahame,

Did you find a way to get around with this problem...
I have the same issue ...

Feb 18, 2016 at 6:19 PM
I am running to a similar issue, is there a solution to getting a EPPlus to work in SQL CLR?

The steps I followed.
  1. I added EPPlus reference to my SQL CLR project "CLRExcel" in VS 2012 using .net framework 4
  2. Tested with a console app. CLRExcel works well, read xlsx files...
  3. On SQL 2012 CREATED ASSEMBLY system.drawing from 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\system.drawing.dll' WITH PERMISSION_SET = UNSAFE; This is required by EEPlus
  4. Then CREATE ASSEMBLY [epplus] from [..HexStream] WITH PERMISSION_SET = UNSAFE;
  5. So far no errors
  6. Now when I try to create my CLRExcel CLR Assembly on SQL I get the error "Assembly 'epplus, version=, culture=neutral, publickeytoken=ea159fdaa78159a1.' was not found in the SQL catalog."
    "using this code
    Create ASSEMBLY [CLRExcel]
    FROM 0x4D5A9000030........