SQL Server stops loading assembly

后端 未结 13 1503
花落未央
花落未央 2020-12-13 00:12

We have developed an assembly for SQL Server 2008 R2.

The assembly has been working for a week. The managed stored proc inside the assembly was working fine for the

13条回答
  •  猫巷女王i
    2020-12-13 00:37

    We saw this error when trying to update spatial columns on a new server which was running SQL Server 2017.

    Credit to the head of IT at our client company who found out that:

    Sql 2017 introduced new trust rules for CLR (SQL 2012 wasn't a problem)... Even 'safe' CLR has to have been signed (which this dll isn't) or you have to force the trust as below:

    DECLARE @clrName nvarchar(4000) = 'sqlspatialtools, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil'
    
    DECLARE @asmBin varbinary(max) = 'PUT THE BINARY STRING HERE (GET FROM SCRIPTING CREATE TO FOR THE EXISTING ASSEMBLY'
    
    DECLARE @hash varbinary(64);
    
    SELECT @hash = HASHBYTES('SHA2_512', @asmBin);
    
    EXEC sys.sp_add_trusted_assembly @hash = @hash, @description = @clrName;
    

    This fixed the issue for us.

提交回复
热议问题