问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/50605927/the-library-libhostpolicy-so-required-to-execute-the-application-was-not-found