Search code examples
sql-serversqlclr

SQLCLR: How to load these dlls to SQL Server 2017?


I have a c# application works with MongoDB using MongoDB NET Driver. The output folder contains this file set:

DnsClient.dll // managed
libsnappy64.dylib
libsnappy64.so
libzstd.dll
libzstd.dylib
libzstd.so
mongocrypt.dll // unmanaged
MongoDB.Bson.dll
MongoDB.Driver.Core.dll
MongoDB.Driver.dll
MongoDB.Libmongocrypt.dll // unmanaged
SharpCompress.dll
snappy32.dll // unmanaged
snappy64.dll// unmanaged
System.Buffers.dll
System.Memory.dll
System.Numerics.Vectors.dll
System.Runtime.CompilerServices.Unsafe.dll
System.Text.Encoding.CodePages.dll
WFMongoDB.exe // my app
WFMongoDB.exe.config

I want to develop my SQLCLR function for work with MongoDB. Some of files are cross-platform dlls and some are unmanaged dlls.

The question is: is it possible to load these files to SQL Server database for using by my SQLCLR function?


Solution

  • Not all of those DLLs will work. The unmanaged DLLs cannot be loaded into SQL Server under any conditions. If they are not required, then try to do without their functionality.

    If they do contain required code, then you might need to keep them as external, make sure they are COM-visible, and then you can call out to them from within SQL Server.