类型或命名空间名称'的mvc'不命名空间中存在'System.Web程序“ [英] The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'

查看:195
本文介绍了类型或命名空间名称'的mvc'不命名空间中存在'System.Web程序“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个混合ASP.NET应用程序MVC1转换为MVC2我收到以下错误,当我尝试运行应用程序后:

After converting a Hybrid ASP.NET MVC1 app to MVC2 I'm getting the following error when I try and run the application:

类型或命名空间名称'的mvc'不会在命名空间System.Web程序存在(是否缺少程序集引用?)

The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

在Web.config文件中的allegeded罪魁祸首是System.Web.Mvc:

The allegeded culprit in the web.config file is System.Web.Mvc:

<namespaces>
    <add namespace="System.Web.Mvc"/>
    <add namespace="System.Web.Mvc.Ajax"/>
    <add namespace="System.Web.Mvc.Html"/>

到目前为止,我的调查似乎导致我相信System.Web.Mvc版本2未安装或没有被拾起。

So far my investigation seems to lead me to believe that version 2 of System.Web.Mvc is not installed or has not been picked up.

我试着创建一个文件>新建项目基于MVC 2和的拿起MVC的新(V2)的版本。我也转换了一些其他项目(即没有混合动力),他们没有任何问题已经转换为MVC2。

I've tried creating a File > New Project based on MVC 2 and that's picking up the new (v2) version of MVC. I've also converted some other projects (that were not hybrids) and they've converted without problem to MVC2.

我也卸载MVC1尝试从GAC删除其引用。然而,这一切都不工作过。

I've also uninstalled MVC1 to try and remove references to it from the GAC. However, none of this has worked.

任何想法?

推荐答案

请确保您有约束力重定向你的web.config:

Make sure you have the binding redirect in your Web.config:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Web.Mvc" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

这迫使M​​VC 2即使MVC 1是在机器上。

This forces MVC 2 even if MVC 1 is on the machine.

另外:MVC 1确实有一个 System.Web.Mvc 命名空间,所以一定要确保你也有:

Also: MVC 1 does have a System.Web.Mvc namespace, so make sure you also have:

  <assemblies>
    <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

这篇关于类型或命名空间名称'的mvc'不命名空间中存在'System.Web程序“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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