I wrote a SQL CLR function in C# that has some dependency (to npgsql.dll). When it didn't have any dependency in the past, I can add it as a new assembly in SQL Server without any problem - but now I can't do it.
I get this error:
Msg 10301, Level 16, State 1, Line 17
Assembly 'Database1' references assembly 'system.directoryservices, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', 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.
Edited: This problem is not just with 'system.directoryservices', so when i use another npgsql.dll i get following error instead:
Msg 10301, Level 16, State 1, Line 20 Assembly 'Database1' references assembly 'system.threading.tasks.extensions, version=4.1.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51.', 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.
and any try to add these library to GAC with Developer Command Prompt doesn't work.
System.DirectoryServicesis loaded from the GAC. In SQL Server, those circumstances do not apply. It has its own logic for loading assemblies and ignores the GAC, except for a small list of whitelisted assemblies that are permitted -- of whichSystem.DirectoryServicesis not one. It (and its dependencies, in turn) must be added to SQL Server's assembly collection explicitly before it's usable. Apparently, earlier versions of the assemblies you already have simply didn't reference it.