Search code examples
c#sql-serversqlclr

SQLCLR-Publish fail for project using ICSharpCode.SharpZipLib


I have a sql clr that has a few functions and Stored procedures. I have the project in an EXTERNAL_ACCESS mode and a key for signing. - works just fine.

I have added another function to the project that uses the ICSharpcode.SharpZipLib. I initially got an incompatibility error for the versions, which I think I resolved following instructions on another post.

The project buids ok, but now I get the following error during that last phase of my project (SQL server db project). This is on my local machine, where I have admin privileges.

Creating [ICSharpCode.SharpZipLib]... (47,1): SQL72014: .Net SqlClient Data Provider: Msg 6211, Level 16, State 1, Line 1 CREATE ASSEMBLY failed because type '<PrivateImplementationDetails>' in safe assembly 'ICSharpCode.SharpZipLib' has a static field '$$method0x6000014-1'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language. (47,0): SQL72045: Script execution error. The executed script: CREATE ASSEMBLY [ICSharpCode.SharpZipLib] AUTHORIZATION [dbo] FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C0103003877BE5A0000000000000000E00002210B010B000000020000200000000000009E1B02000020000000200200000040000020000000100000040000000000000004000000000000000060020000100000000000000300408500001000001000000000100000100000000000001000000000000000000000004C1B02004F000000002002003804000000000000000000000000000000000000004002000C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000A4FB0100002000000000020000100000000000000000000000000000200000602E7273726300000038040000002002000010000000100200000000000000000000000000400000402E72656C6F6300000C000000004002000 An error occurred while the batch was being executed.

Appreciate any help ! Thx, Satya


Solution

  • I guess the first thing would be to see if you could do without IcSharpcode.SharpZipLib. If not then:

    If you have access to the source for IcSharpcode.SharpZipLib you could change the static to be read-only.

    Last option is to deploy the assemblies with PERMISSION_SET = UNSAFE.