Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly (nopcommerce 3.5) when changing to release

I have a new nopcommerce 3.5 website that i want to publish and on debug it all was well but as soon i changed to release im getting this error

Error   1   Could not load file or assembly 'file:///C:\Users\User\Desktop\nop\packages\Autofac.3.5.2\lib\net40\Autofac.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)   C:\Users\User\Desktop\nop\Libraries\Nop.Services\SGEN   Nop.Services

and i looked all over the web and did all i could and it is just not working

what i did.

  1. clean and rebuild
  2. restart vs
  3. i re-downloaded a fresh copy of the code and the same happened
  4. deleted all the references and rebuilt
like image 590
CMS Avatar asked May 20 '15 21:05

CMS


3 Answers

OK here is how i solved it.

The files were locked by windows and its only visible in debug

I had to go to each .dll file that showed up in the error, and in the properties there was a button UNBLOCK and ones i applied the changes the errors was gone

like image 164
CMS Avatar answered Sep 18 '22 12:09

CMS


Instead of unblock all files one by one, you can do it from root folder by using Windows PowerShell:

dir D:\Projects\Nop -recurse | Unblock-File

like image 27
Soon Khai Avatar answered Sep 21 '22 12:09

Soon Khai


To unblock files use this command on Windows Powershell:

gci PASTE_FOLDER_PATH_HERE\*.dll -Recurse | Unblock-File

1) "gci" is used to load all files located under the specified path.
2) "-Recurse" is used to load files located in sub folders under the specified path.

like image 36
user3125999 Avatar answered Sep 18 '22 12:09

user3125999