Asp.net-Mvc-4

添加參考列表中缺少 System.Web.Http.Description

  • October 15, 2018

我收到一個錯誤:

Error   1   The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?) c:\users\klippiat\documents\visual studio 2010\Projects\TfsPortal\TfsPortal\Models\ApiModel.cs  5   23  TfsPortal

我通常會添加參考並選擇缺少的參考。但從System.Web.Http.Description列表中失去。我已經按名稱對列表進行了排序,以確保我應該能夠看到它。我可以看到System.Web.Http.Data和 .Common 等,但不是 .Description 之一。

我究竟做錯了什麼?

Visual Studio 2012 SPA 模板 /Help/index.cshtml 文件引發了您的錯誤。

@using System.Web.Http
@using System.Web.Http.Description  <=== CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)

**解決方案:**在 References\System.Web.Http 的屬性中設置“Copy Local : True”

你沒有做錯什麼。只是有一些配置問題阻止 Visual Studio 添加對程序集列表的引用以供編譯器檢查。

中的類型System.Web.Http.Description可在System.Web.Http.dll程序集中找到,該程序集位於Nuget封包件夾中。

您可以Uninstall-Package Microsoft.AspNet.WebApiNuGet 包控制台中鍵入,然後鍵入Install-Package Microsoft.AspNet.WebApi以重新安裝它,此時引用將被修復。

引用自:https://stackoverflow.com/questions/12271431