简体   繁体   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?)

I'm having namespaces error in ASP.Net MVC WebAPI. 我在ASP.Net MVC WebAPI中遇到名称空间错误。 I'm using MVC 4 with .Net Framework 4.5, while running the application It works but on the click of API it displays error like below. 我在运行应用程序时将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
    -----------------------------------------------------------------------------------

Below is the where namespace is missing. 下面是缺少名称空间的地方。 I tried to reinstall mvc 4 but it comes with many more error. 我试图重新安装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>

Try below things: 尝试以下事情:

1) Try Setting 'Copy local: true' in Properties tab in References\\System.Web.Http 1)尝试在References \\ System.Web.Http的“属性”选项卡中设置“复制本地:true”

2) If above doesn't work , try Uninstalling Package Microsoft.AspNet.WebApi in the NuGet Package Console and then re-install it. 2)如果上述方法不起作用,请尝试在NuGet软件包控制台中卸载Microsoft.AspNet.WebApi软件包,然后重新安装。

Sometimes de reference to System.Web doesn't recognize the correct version. 有时,对System.Web的取消引用无法识别正确的版本。

Try to add it manually using Browse option on Add Reference. 尝试使用“添加引用”上的“浏览”选项手动添加它。

It was .Net framework issue. 这是.Net框架问题。 I've Updated .Net framework to latest and error has gone. 我已经将.Net框架更新到最新,并且错误已经消失了。 Still I'm not sure that this is the resolution but somehow It worked form me. 仍然我不确定这是否是解决方案,但是以某种方式它对我有效。

Thanks for the response! 感谢您的回复!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CS0234:类型或名称空间名称“ WebPages”在名称空间“ System.Web”中不存在(您是否缺少程序集引用?) - CS0234: The type or namespace name 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 错误 CS0234 命名空间“Microsoft”中不存在类型或命名空间名称“Reporting”(您是否缺少程序集引用?) - Error CS0234 The type or namespace name 'Reporting' does not exist in the namespace 'Microsoft' (Are you missing an assembly reference?) 错误 CS0234:命名空间“Microsoft”中不存在类型或命名空间名称“Azure”(您是否缺少程序集引用?) - error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) CS0234 C#类型或名称空间名称&#39;Slydeextender&#39;在名称空间中不存在(您是否缺少程序集引用?) - CS0234 C# The type or namespace name 'Slydeextender' does not exist in the namespace (are you missing an assembly reference?) 错误 CS0234 命名空间“MvvmCross”中不存在类型或命名空间名称“平台”(您是否缺少程序集引用?) - Error CS0234 The type or namespace name 'Platforms' does not exist in the namespace 'MvvmCross' (are you missing an assembly reference?) MEF CS0234:名称空间&#39;System.ComponentModel&#39;中不存在类型或命名空间名称&#39;Composition&#39;(您是否缺少程序集引用?) - MEF CS0234: The type or namespace name 'Composition' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) CS0234:命名空间“<namespace1>”中不存在类型或命名空间名称“<namespace2>”。 (你错过了一个程序集引用吗?) - CS0234: The type or namespace name '<namespace2>' does not exist in the namespace '<namespace1>.' (are you missing an assembly reference?) 错误CS0234:类型或名称空间名称&#39;OAuth&#39;在名称空间&#39;Microsoft.Owin.Security&#39;中不存在(您是否缺少程序集引用?) - error CS0234: The type or namespace name 'OAuth' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?) VS 2017 c#错误CS0234命名空间中不存在类型或命名空间名称(您是否缺少程序集引用?) - VS 2017 c# Error CS0234 The type or namespace name does not exist in the namespace (are you missing an assembly reference?) 编译器错误消息:CS0234:命名空间“传真”中不存在类型或命名空间名称“WebApp”(您是否缺少程序集引用?) - Compiler Error Message: CS0234: The type or namespace name 'WebApp' does not exist in the namespace 'Fax' (are you missing an assembly reference?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM