Error during the registration of a CLR assembly in SQL Server 2017 which references other assembly

Imran Shamszadeh 26 Reputation points
2020-08-26T15:05:18.123+00:00

I got the following error when I try to deploy my DLL which references other ThirdPartyDLL.

Msg 10300, Level 16, State 2, Line 4
Assembly 'MYDLL' references assembly 'ThirdPartyDLL, version=300.1.0.1, culture=neutral, publickeytoken=5c915cbb2b8fbc32.', 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: version, culture or public key mismatch). Please load the referenced assembly into the current database and retry your request.

I used this statement to deploy my dll:
20624-dll-error-2.jpg

I'm sure the ThirdPartyDLL is correctly installed but I get the error base on mismatching!!! For example result of this:
20633-dll-error-3.jpg

is:
20563-dll-error.jpg

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,489 questions
No comments
{count} votes

Accepted answer
  1. Guoxiong 7,681 Reputation points
    2020-08-26T17:53:53.087+00:00

1 additional answer

Sort by: Most helpful
  1. Miamiao-MSFT 4,216 Reputation points
    2020-08-27T05:52:54.61+00:00

    Hi @Imran Shamszadeh ,

    Try code as next:

    ALTER DATABASE [xxxx] SET TRUSTWORTHY ON;  
    sp_configure 'clr enabled', 1;  
    RECONFIGURE;  
      
      
    CREATE ASSEMBLY [xxxx] AUTHORIZATION [xxxx]  
    FROM 'C:\CLR\MyAssembly.dll'  
    WITH PERMISSION_SET = SAFE  
    

    More information: https://dba.stackexchange.com/questions/12479/3rd-party-dll-in-sql-server-clr , https://www.sqlshack.com/impact-clr-strict-security-configuration-setting-sql-server-2017/

    BR,
    Mia
    If the reply helped, please do “Accept Answer”.