簡體   English   中英

CS0234:類型或名稱空間名稱“ Description”在名稱空間“ System.Web.Http”中不存在(您是否缺少程序集引用?)

[英]CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)

我在ASP.Net MVC WebAPI中遇到名稱空間錯誤。 我在運行應用程序時將MVC 4與.Net Framework 4.5一起使用它可以工作,但是在單擊API時它顯示如下錯誤。

    ------------------------------------------------------------------------------------
    Server Error in '/' Application.

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)

    Source Error:
    Line 1:  @using System.Web.Http
    Line 2:  @using System.Web.Http.Description
    Line 3:  @using System.Collections.ObjectModel
    Line 4:  @using SmartCare360APIs.Areas.HelpPage.Models

    Source File: e:\Projects\SmartCare 360\Code\SmartCare360APIs\SmartCare360APIs\Areas\HelpPage\Views\Help\Index.cshtml    Line: 2

    Show Detailed Compiler Output:
    Show Complete Compilation Source:

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1637.0
    -----------------------------------------------------------------------------------

下面是缺少名稱空間的地方。 我試圖重新安裝mvc 4,但它附帶了更多錯誤。

Page : **ApiGroup.cshtml**

 @using System.Web.Http
 @using System.Web.Http.Description
 @using SmartCare360APIs.Areas.HelpPage
 @using SmartCare360APIs.Areas.HelpPage.Models
 @model IGrouping<string, ApiDescription>

 <h2 id="@Model.Key">@Model.Key</h2>
 <table class="help-page-table">
 <thead>
                <tr><th>API</th><th>Description</th></tr>
            </thead>
            <tbody>
            @foreach (var api in Model)
            {
                <tr>
                    <td class="api-name"><a href="@Url.Action("Api", "Help", new { apiId = api.GetFriendlyId() })">@api.HttpMethod.Method @api.RelativePath</a></td>
                    <td class="api-documentation">
                    @if (api.Documentation != null)
                    {
                        <p>@api.Documentation</p>
                    }
                    else
                    {
                        <p>No documentation available.</p>
                    }
                    </td>
                </tr>
            }
            </tbody>
        </table>

嘗試以下事情:

1)嘗試在References \\ System.Web.Http的“屬性”選項卡中設置“復制本地:true”

2)如果上述方法不起作用,請嘗試在NuGet軟件包控制台中卸載Microsoft.AspNet.WebApi軟件包,然后重新安裝。

有時,對System.Web的取消引用無法識別正確的版本。

嘗試使用“添加引用”上的“瀏覽”選項手動添加它。

這是.Net框架問題。 我已經將.Net框架更新到最新,並且錯誤已經消失了。 仍然我不確定這是否是解決方案,但是以某種方式它對我有效。

感謝您的回復!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 CS0234:類型或名稱空間名稱“ WebPages”在名稱空間“ System.Web”中不存在(您是否缺少程序集引用?) 錯誤 CS0234 命名空間“Microsoft”中不存在類型或命名空間名稱“Reporting”(您是否缺少程序集引用?) 錯誤 CS0234:命名空間“Microsoft”中不存在類型或命名空間名稱“Azure”(您是否缺少程序集引用?) CS0234 C#類型或名稱空間名稱&#39;Slydeextender&#39;在名稱空間中不存在(您是否缺少程序集引用?) 錯誤 CS0234 命名空間“MvvmCross”中不存在類型或命名空間名稱“平台”(您是否缺少程序集引用?) MEF CS0234:名稱空間&#39;System.ComponentModel&#39;中不存在類型或命名空間名稱&#39;Composition&#39;(您是否缺少程序集引用?) CS0234:命名空間“<namespace1>”中不存在類型或命名空間名稱“<namespace2>”。 (你錯過了一個程序集引用嗎?) 錯誤CS0234:類型或名稱空間名稱&#39;OAuth&#39;在名稱空間&#39;Microsoft.Owin.Security&#39;中不存在(您是否缺少程序集引用?) VS 2017 c#錯誤CS0234命名空間中不存在類型或命名空間名稱(您是否缺少程序集引用?) 編譯器錯誤消息:CS0234:命名空間“傳真”中不存在類型或命名空間名稱“WebApp”(您是否缺少程序集引用?)
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM