'The library 'libhostpolicy.so' required to execute the application was not found

During running a dotnet console application I encountered this error. I ran it from a directory that had the .dll and .pdb file copied into it.

What is the cause of this error?



Solution 1:[1]

Please check chmod of application folder. When I change folder access mode, problem was resolved. I know it is a little weird but sometimes it can be related to that :)

You have to determine them like that;

sudo chown -R yourusername:yourusername /var/www/
sudo setfacl -R -d -m u:yourusername:rwx,g:yourusername:rwx,o::r /var/www/

If you don't have setfacl command please install ACL package via this command;

sudo apt install acl

If this doesn't work, please use this command when publishing your project(in Package Manager Console of Visual Studio);

dotnet publish -c Release --self-contained --runtime linux-x64 -o out

And it will create "out" folder in your solution directory, you can copy its contain to server.

Solution 2:[2]

the deps.json and runtimeconfig.json must also be copied into the directory that the .dll is invoked in. Without these files you will encounter this error.

If you're doing post-build copies, make sure to include these files.

Solution 3:[3]

I receive this error when I had compiled the dll using the incorrect runtime.

Running a linux-x64 binary on a linux-arm64 system will show this error and vice versa.

Solution 4:[4]

If you are running a solution that has multiple projects, check to make sure the correct startup project is set.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mirac
Solution 2 David Hunsicker
Solution 3 Mike Smith
Solution 4 robbpriestley