Reputation: 1240
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?
Upvotes: 8
Views: 17677
Reputation: 732
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.
Upvotes: 2
Reputation: 3300
If you are running a solution that has multiple projects, check to make sure the correct startup project is set.
Upvotes: -1
Reputation: 138
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.
Upvotes: 5
Reputation: 1240
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.
Upvotes: 1