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


I just recently published my 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
 sudo dotnet publish -c release -o /var/www/

Then restart afterward

 sudo systemctl restart nginx
 sudo systemctl stop
 sudo systemctl enable
 sudo systemctl start
 sudo systemctl status
 sudo journalctl -fu

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=, 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 !!


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