skip to Main Content

I am using a native code DLL in an ASP.NET Core .NET 6 application. I have compiled both a DLL for windows and a .so for Linux. I invoke it with the DLLImport attribute and the .NET loader is normally able to find the file both on Windows and Linux. The native code DLL is copied into the application output directory alongside the rest of the compiled .NET code.

The application works both on Windows and on a test install on Ubuntu in a VM. However when running on Azure App Service (Linux) I get the error :

Unable to load shared library ‘mylib’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libmylib: cannot open shared object file: No such file or directory

The application is deployed via Azure DevOps Pipelines using these publish arguments:

arguments: ‘–configuration $(BuildConfiguration) -r linux-x64 –self-contained true –output $(Build.ArtifactStagingDirectory)’

Azure DevOps Pipelines is able to run unit tests for the application including those which call the native library.

I used SSL and Bash to inspect the file system in Azure App Service and I can see that libmylib.so is present in the directory alongside the rest of the compiled .NET code.

I tried copying it to /usr/local/lib and it still didn’t work.

What do I need to do to call this file successfully in Azure App Service? Could I be getting the error because some other dependency is missing?

2

Answers


  1. Chosen as BEST ANSWER

    The issue here is that the official .NET 6.0 runtime container mcr.microsoft.com/dotnet/aspnet:6.0 currently runs debian buster and the version of glibc is 2.28 which was too old for one of my dependencies.

    The .NET 7.0 runtime container is OK but I haven't tried upgrading yet.

    The solution I found was to download debian buster and recompile my shared library. This now works, together with installing libgomp1.


  2. You can log in kudu site, the site url should like:

    https://your_sitename.scm.azurewebsites.net/newui
    

    Then click the webssh, then run the command to install.

    apt-get install libgomp1
    

    If it not works, you can run the apt-get update and apt-get install g++. For more details, please check the test steps which I have test.

    And I also have a workaround:

    You can create the webapp with docker container. You just make sure it works well in your local.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search