HttpConfiguration失踪总成 [英] HttpConfiguration missing assembly

查看:1300
本文介绍了HttpConfiguration失踪总成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立使用MVC4网站。我甚至不能开始说我有一个奇怪的错误。这是我的code:

I am building a site using MVC4. I couldn't even begin that I am having a strange error. This is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;

namespace MyProject
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}

错误消息:程序集HttpConfiguration'的类型或名称中不存在命名空间'System.Web.Http(是否缺少using指令或程序集引用)

The error message: The type or name of the assembly 'HttpConfiguration' does not exist in the namespace 'System.Web.Http' (are you missing a using directive or an assembly reference?)

它也不会承认只读字段RouteParameter。它发生,我认为它可能有一些做的版本,我的System.Web DLL是4.0.0.0版本。

It also doesn't recognize the readonly field RouteParameter. It occurs to me that it may have something to do with the version, my System.Web dll is version 4.0.0.0.

另一个信息附加部分是,当我输入使用的System.Web,智能感知识别.Http DLL

Another additional piece of information is that when I type "using System.Web. ", Intellisense DOES recognize the .Http dll

不过,在code,它不承认任何参数。

HOWEVER, in the code, it does not recognize any of its parameters.

推荐答案

我解决它。问题是,当我创建的网站,我通过的NuGet更新的包。然而,正如我wasn't要使用实体框架,我卸载它。为了能够卸载包,它要求我卸载Microsoft.AspNet.Providers.Core 1.2,以及...和我做到了。

I solved it. The issue was that, when I created the site, I updated all packages via Nuget. However, as I wasn´t going to use Entity Framework, I uninstalled it. In order to be able to uninstall that package, it required for me to uninstall Microsoft.AspNet.Providers.Core 1.2 as well... and I did.

这缺失的软件包把事情搞乱。我清除了项目,各地又开始了。我可以在PM控制台中也有使用更新-Package命令,并且会恢复所有丢失的包。然而,因为我已经做了这么多乱七八糟比较小(旁边空)的工作,我做了,我决定从头再来吧。

This missing package messed things up. I cleared the project and started all over again. I could have also used the Update-Package command in the PM Console and would have restored all lost packages. However, since I had done so much mess compared to the little (next to null) work I had done, I decided to start it all over again.

不管怎样,谢谢!

这篇关于HttpConfiguration失踪总成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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