Windows升级&QUOT后,该类型或命名空间名称“HTML”不会在命名空间'System.Web.Mvc'&QUOT存在; [英] After Windows update "The type or namespace name 'Html' does not exist in the namespace 'System.Web.Mvc'"

查看:297
本文介绍了Windows升级&QUOT后,该类型或命名空间名称“HTML”不会在命名空间'System.Web.Mvc'&QUOT存在;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了Windows Update和事后我的asp.net mvc的5应用程序将不再负荷抱怨

I did a Windows update and afterwards my asp.net mvc 5 application will no longer load complaining about

CS0234: The type or namespace name 'Html' does not exist in the namespace 'System.Web.Mvc'

说明我的观点的web.config是有过错的。

indicating my views web.config is at fault

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="Ogre.Extensions" />
        <add namespace="Newtonsoft.Json"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>

现在,这是非常混乱。在我的项目本身,我可以看到 HTML 命名空间,打开我的装配ILSpy我可以导航到绑定的 System.Web.Mvc ,我可以作为很好,融合日志没有显示任何可疑绑定错误。

Now this is very confusing. In my project itself I can see the Html namespace, opening my assembly in ILSpy I can navigate to the bound System.Web.Mvc and I can it as well, and the fusion log is not showing any suspicious binding errors.

这是因为如果的只是的我的看法越来越约束(成功),以一个老版本的MVC。为什么会发生?我怎样才能解决这个问题?

It's as if just my views are getting bound (successfully) to an old version of Mvc. Why would that ever happen? How can I fix it?

让我清楚的是没有出现过的配置,甚至code的变化。这是所有关于IISEx preSS我的dev的机器上。它运行,我做了更新并重新启动,现在它不再运行。

Let me be clear that there have been no configuration or even code changes. This is all on my dev machine on IISExpress. It was running, I did the update and rebooted and now it is no longer running.

下面是我最近在更新安装。我可以开始一个去除它们,但我想知道什么是真正走错了,因为它感觉就像我错过了故事的一部分。

Here are my recent installs from the update. I could start removing them one by one, but I want to know what is actually going wrong as it feels like I'm missing part of the story.

推荐答案

哇靠,感谢@内华达Williford的提示。要在我的 System.Web.Mvc 引用设置为&LT;私人和GT;真&LT; /私募&GT; (复制本地= TRUE)固定它。请注意,更新一切工作之前,更新后我不得不修改我的csproj得到它的工作了。

Holy crap, thanks to @Nevada-Williford for the hint. Going in and setting my System.Web.Mvc reference to <Private>True</Private> (Copy Local = True) fixed it. Note, that before the update everything was working, after the update I had to modify my csproj to get it working again.

上发生了什么工作原理:

复制本地=真&LT;私人和GT;真&LT; /私募&GT; 曾经是差不多,<一个href=\"http://blogs.msdn.com/b/jjameson/archive/2009/11/18/the-copy-local-bug-in-visual-studio.aspx\">but不完全,同样的事情。的,前者是一个Visual Studio设置,后者一个MSBuild设置。如果设置的MSBuild缺席,Visual Studio的设置将被应用(只要你在VS)。在这次更新中,我认为他们改变它,复制本地只是反映了presence属性。

Copy Local = True and <Private>True</Private> used to be almost, but not exactly, the same thing. The former was a Visual Studio setting, the latter an msbuild setting. If the msbuild setting was absent, the Visual Studio setting would be applied (as long as you were in VS). In this update I think they changed it so Copy Local just reflects the presence attribute.

在我们的项目,我们没有这样的属性明确设置,但复制本地=真所以之前的更新 System.Web.Mvc.dll程序被复制到bin目录。更新后,因为属性缺少复制本地显示,你必须将它设置为,以确保你得到一个本地副本。

In our project we do not have that attribute set explicitly but Copy Local = True so prior to the update System.Web.Mvc.dll gets copied to the bin directory. After the update, since the attribute is missing Copy Local shows False and you have to set it to True to make sure you get a local copy.

手动设置复制本地=真(或添加XML元素的MSBuild)修复该问题。

Manually setting Copy Local = True (or adding that xml element to msbuild) fixes the issue.

编辑:虽然这似乎是答案的具体问题,任何人都来到这里应该读评论跟帖和其他答案 - 尤其是dmatson的 - 更多的情况下,解释和相关的错误

While this appears to be the answer to the specific question, anyone coming here should read the comment thread and other answers - especially dmatson's - for more context, caveats, and related bugs.

这篇关于Windows升级&QUOT后,该类型或命名空间名称“HTML”不会在命名空间'System.Web.Mvc'&QUOT存在;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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