无法加载文件或程序集“System.Net.Http.Formatting"或其依赖项之一.该系统找不到指定的路径 [英] Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified

查看:30
本文介绍了无法加载文件或程序集“System.Net.Http.Formatting"或其依赖项之一.该系统找不到指定的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于练习的小型 MVC 应用程序,但现在每次尝试调试时都会遇到错误:

I have a small MVC app that I use for practice reasons, but now I am encountering an error every time I try to debug:

Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. 
The system cannot find the path specified.

我用谷歌搜索过,但找不到解决方案.我使用的是 .NET 4.5.

I've googled but cannot find a solution. I'm using .NET 4.5.

它不能是 DLL 文件,因为我使用的是 .Net 4.5.

It can't be the DLL file because I'm using .Net 4.5.

推荐答案

每当我遇到此类 NuGet 错误时,我通常会采取以下步骤:

Whenever I have a NuGet error such as these I usually take these steps:

  1. 转到 Windows 资源管理器中的包文件夹并将其删除.
  2. 打开 Visual Studio 并转到 Tools > Library Package Manager > Package Manager Settings 并在左侧的 Package Manager 项下有一个清除包缓存"按钮.单击此按钮并确保选中允许 NuGet 在构建期间下载丢失的包"复选框.
  3. 清洁溶液
  4. 然后在解决方案资源管理器中右键单击解决方案并启用 NuGet 包还原
  5. 构建解决方案
  6. 重启 Visual Studio
  1. Go to the packages folder in the Windows Explorer and delete it.
  2. Open Visual Studio and Go to Tools > Library Package Manager > Package Manager Settings and under the Package Manager item on the left hand side there is a "Clear Package Cache" button. Click this button and make sure that the check box for "Allow NuGet to download missing packages during build" is checked.
  3. Clean the solution
  4. Then right click the solution in the Solution Explorer and enable NuGet Package Restore
  5. Build the solution
  6. Restart Visual Studio

采取所有这些步骤几乎总能恢复我的 MVC 程序所需的所有包和 dll.

Taking all of these steps almost always restores all the packages and dll's I need for my MVC program.

编辑 >>>

对于 Visual Studio 2013 及更高版本,步骤 2) 应为:

For Visual Studio 2013 and above, step 2) should read:

  1. 打开 Visual Studio 并转到 Tools > Options > NuGet Package Manager,在右侧有一个Clear Package Cache按钮".单击此按钮并确保选中允许 NuGet 下载丢失的包"和在 Visual Studio 中构建期间自动检查丢失的包"复选框.
  1. Open Visual Studio and go to Tools > Options > NuGet Package Manager and on the right hand side there is a "Clear Package Cache button". Click this button and make sure that the check boxes for "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" are checked.

这篇关于无法加载文件或程序集“System.Net.Http.Formatting"或其依赖项之一.该系统找不到指定的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆