Dotnet driver v2.14.1 error: "Unable to load shared library 'libdl' or one of its dependencies"

I get Unable to load shared library 'libdl' or one of its dependencies exception when initializing the client in this specific case:

  • .NET 6.0
  • MongoDB.Driver v2.14.1
  • Explicitly setting ZStandard or Snappy connection compression with MongoClientSettings
  • Production build for application
  • Running inside MS official Runtime container image

Worth noting that:

  • Process works fine (no exceptions) when running in Dev container with the full .NET 6.0 SDK
  • Process works fine in the Runtime .NET image when specifying Noop for connection compression

Hi, @Bobby_Kotzev,

Welcome to the MongoDB user community! We understand that you are attempting to build and run a .NET application using the MongoDB .NET/C# Driver v2.14.1 but are receiving the following error when you enable snappy or zstd compression:

Unable to load shared library ‘libdl’ or one of its dependencies

The driver implements snappy and zstd compression using unmanaged compression libraries, which are dynamically loaded using the dynamic loader This error indicates that the CLR cannot find in the Docker image. is part of the Linux operating system, though is sometimes stripped out of minimal images. The .NET 6.0 devcontainer likely has included whereas the production image does not. You’ll have to modify your Dockerfile to include the appropriate package that contains


1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.