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

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

我在谷歌上搜索过,但找不到解决方案.我在用.净4.5.

它不可能是DLL文件,因为我使用的是.NET4.5.

推荐答案

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

  1. 转到Windows资源管理器中的Packages文件夹并将其删除.
  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. 清洗溶液
  4. 然后在解决方案资源管理器中右键单击该解决方案并启用NuGet Package Restore
  5. 构建解决方案
  6. 重新启动Visual Studio

执行所有这些步骤几乎总是可以恢复我的MVC程序所需的所有包和DLL.


EDIT >>>

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

  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.

Asp.net相关问答推荐

将 Response.Headers.Add 替换为方法属性decorator

如何在 C#/MVC 4 中的 Html.TextBoxFor 中输入占位符文本

无法为媒体类型application/x-www-form-urlencoded生成样本

如何从 JavaScript 调用 C# 函数?

Web API Queryable - 如何应用 AutoMapper?

asp.net、url 重写模块和 web.config

ASP.NET 平台是否有与 Heroku 等价的工具?

ASP.NET 在更新面板更新时显示正在加载...消息

这两种方法有什么区别?

排序下拉列表? - C#,ASP.NET

防止在 Visual Studio 2008 ASP.NET Web 窗体中复制粘贴时自动生成 ID

如何将枚举类型绑定到 DropDownList?

如何在 ASP.NET 页面中以编程方式生成 401 错误

缩小 ASP.NET 应用程序的 Html 输出

我的 asp.net mvc Web 应用程序中的 OutputCache 设置.防止缓存的多种语法

如何在我自己的方法中模仿 string.Format()?

如何将我的 DDD 模型中的用户与身份验证用户集成?

使 WCF Web 服务与 GET 请求一起工作

在控制器 asp.net-core 中获取当前区域性

在没有等待 #2 的情况下调用异步方法