System.IO.FileNotFoundException: Could not load file or assembly 'FluentAssertions, Version=5.10.3.0

Issue

I just recently published my asp.net api with linux and everything worked just fine.
Then I decided to make some changes to my code:

  • Delete email service that I no longer need. I already ensured that it did not have any reference to others.

I pulled new changes to the hosting server from github and then redeployed with below commands.

 cd myapp.Api
 sudo dotnet clean
 sudo dotnet build --configuration Release
 sudo systemctl stop myappweb.com.service
 sudo dotnet publish -c release -o /var/www/myappweb.com/api/

Then restart afterward

 sudo systemctl restart nginx
 sudo systemctl stop myappweb.com.service
 sudo systemctl enable myappweb.com.service
 sudo systemctl start myappweb.com.service
 sudo systemctl status myappweb.com.service
 sudo journalctl -fu myappweb.com.service

Then the error occured, even though my local application still working just fine.

 * Unhandled exception. System.IO.FileNotFound. Could not load file or assembly 'FluentAssertions, Version=5.10.3.0, Culture=neutral, PublicKeyToken=22f2441a05b241b4a'. The system cannot find the file specified.*

I already checked the version, its the same.
And right away I reverted the commit on github and tried to redeploy but it still generated the same error.

I would appreciate any help or suggestions on what the real problem is !!

Solution

Turned out that at the last deployment I did not switch to the myApp.api directory and end up deployed at the wrong directory thats why it could not find some files.
To resolve, all assemblies with .dll extension have to be deleted and make a clean rebuild.

Answered By – Tai Tsan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published