By using AWS re:Post, you agree to the Terms of Use
/Unable to load shared library '' or one of its dependencies/

Unable to load shared library '' or one of its dependencies


I've created a .NET 6 CONTAINER IMAGE C# lambda function using visual studio. My function will ultimately utilize to query active directory.

This package requires that openldap be installed, which it is natively installed on the Amazon Linux 2 docker container image I'm using for this lambda function.

I am running into the error below upon invocation of the published lambda.

  "errorType": "DllNotFoundException",
  "errorMessage": "Unable to load shared library '' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: cannot open shared object file: No such file or directory",
  "stackTrace": [
    "at LdapForNet.Native.NativeMethodsLinux.ldap_initialize(IntPtr& ld, String uri)",
    "at LdapForNet.Native.LdapNativeLinux.Init(IntPtr& ld, String url)",
    "at LdapForNet.LdapConnection.Connect(String url, LdapVersion version)",
    "at LdapForNet.LdapConnectExtensions.Connect(ILdapConnection connection, Uri uri, LdapVersion version)",
    "at LdapForNet.LdapConnectExtensions.Connect(ILdapConnection connection, String hostname, Int32 port, LdapSchema ldapSchema, LdapVersion version)",
    "at hqpoc_lam_net6_docker.Function.ValidateUser(String domainName, String username, String password) in C:\\git\\hqpoc-lam-net6-docker\\hqpoc-lam-net6-docker\\src\\hqpoc-lam-net6-docker\\Function.cs:line 35",
    "at hqpoc_lam_net6_docker.Function.FunctionHandler(String input, ILambdaContext context) in C:\\git\\hqpoc-lam-net6-docker\\hqpoc-lam-net6-docker\\src\\hqpoc-lam-net6-docker\\Function.cs:line 24",
    "at lambda_method1(Closure , Stream , ILambdaContext , Stream )",
    "at Amazon.Lambda.RuntimeSupport.Bootstrap.UserCodeLoader.Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outStream) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:line 145",
    "at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass8_0.<GetHandlerWrapper>b__0(InvocationRequest invocation) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:line 56",
    "at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:line 176"

I have zipped the relevant binaries into the lambda function directory, like described here:

How can I utilize the native binary 'openldap' in this docker container with my C# lambda function? Thanks!

asked 3 months ago37 views
1 Answers
Accepted Answer


Tim here on the AWS Support Team.

I worked with a few colleagues here at AWS and I do see our AWS ECR Dotnet 6 base image ( includes openldap.

When you mention it’s natively installed I understand that to mean you’re using the one we included when you run your code (so you’ve built your code around the provided openldap package).

The recommendation is to add the following line to your Dockerfile to install openldap, regardless if we include it (so that you’re in total control of your dependencies):

RUN yum install -y openldap

Should the openldap ever be removed from the base image, you bundling it will guarantee it’s always included and installed during your images’ build process.

Just need to note that software development is a bit difficult to troubleshoot and goes a bit easier in the scenario of pair programming (where I’d be right there with you) but I’ve been looking into this on my side my level best.

  • Assuming that you do get it included modifying the Dockerfile, the error does mention to consider setting the LD_DEBUG environment variable.

  • Another item is perhaps permissions on the file, I’ve seen a similar error with our ZIP based Python deployment packages where permissions needed to be changed ( )

  • The final item that could be the cause is how you’re building the container, and this is where I wouldn’t have much visibility myself (the pair programming item I mentioned earlier :^ ) ). Perhaps you can audit these a bit. If your system is pretty clean-cut and the default setup (that is not much modification has been made), it may just be a bit of digging into it with the dotnet language maintainers. I ran across a github issue that appears to be similiar to your own (albeit, not exactly the same issue):

I have a few additional resources that can help. We recently published a blog post (5 days ago as of this writing) on getting started with the dotnet 6 runtime for AWS Lambda here:

Also within the past hour as of this writing, we had a video tutorial from our Serverless Team providing a few demos of the newly released dotnet 6 runtime:

For any further troubleshooting you can check out the aws dotnet GitHub page and submit an issue and they may be ran across this type of error before:

answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions