简体   繁体   中英

dlls missing after publishing .NET Web

My web project use .NET Framework 4.7.2 and use some references like

  • System.IO
  • System.Net
  • System.Net.Http
  • System.Net.Http.Formatting

My project works perfectly in local. However, when I publish my web project on a target directory (for online), and look what it contains in /bin/ :

  • System.IO is missing
  • System.Net is present
  • System.Net.Http is missing
  • System.Net.Http.Formatting is present

Therefore, when I use my website, I get the obvious error Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

All references have Copy Local = True in Properties but some dll are always ignored. If i copy the dlls from local directory to target directory i get the error Server Error in '/' Application. Cannot load a reference assembly for execution. Exception Details: System.BadImageFormatException: Cannot load a reference assembly for execution. Server Error in '/' Application. Cannot load a reference assembly for execution. Exception Details: System.BadImageFormatException: Cannot load a reference assembly for execution. Exactly the same problem as this one. However the delete/rebuild solution, or adding compilation options solution, doesn't work for me

What do I need to do to get these missing dlls to the destination folder?

Go to Solution Explorer on VS, open references tree, right click on the library(dll) and select properties on the menu. On properties box Copy Local should be True

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM