使用nuget将项目中MVC4 升级到MVC5,之后项目还可以正常编译运行,

但View视图中相关的很多代码都报错,比如:

1.@model找不到

2.@Html找不到,本该是System.Web.MVC的HtmlHelper,系统却将其认成是

System.Web.WebPages.HTML.HtmlHelper

参考地址 http://stackoverflow.com/questions/4605263/viewbag-title-error

解决方法及原因:System.Core冲突,直接将3.5版本的System.Core删掉,只保留4.0的即可

I solved it in the following way:

First i noticed using gacutil (Global Assembly Cache Utility) that it contained two references to System.Core, one to version 4.0 and one to version 3.5. Apparently inside the razor views, even if in the project i had the correct reference to version 4.0, it was still using version 3.5 and that's why i was getting the error about the dynamic types. To check if that's your case open as administrator Visual Studio Command Prompt and execute:

gacutil -l System.Core

To remove the reference to the old version of System.Core i did the following steps:

- cd %systemroot%\assembly\

From here you may have more that one "gac" directory, so you will have to search within each to find your component. For me, it was within the "gac_MSIL" directory.

- cd gac_msil

- cd System.Core
- cd <assembly version number>__<public key token>
- erase *.* Say "y" to are you sure.
- cd ..
- rd <assembly version number>__<public key token>
- cd ..
- rd System.Core

After that I opened my solution again in visual studio and the error was gone, it references properly to System.Core 4.0 and I was not getting the dynamic errors anymore :)

I hope it will help you as well, Best, N.

我运行的时候,提示我没有权限删除,然后在web.config里面添加

<compilation debug="true" targetFramework="4.0">
    <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </assemblies>
</compilation>

就可以解决,写上以此备忘。

还有救是System.Web.Mvc 这个文件复制到本地

ViewBag 出现 找不到编译动态表达式所需的一种或多种类型。是否缺少引用?

需要引用 Microsoft.CSharp

最新文章

  1. Python标准模块--Unicode
  2. 关于IIS部署时出现“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本”的问题解决摘要
  3. c#无损高质量压缩图片
  4. 取代file_get_contents 的一个采集函数
  5. HDU 3085 Nightmare Ⅱ (双向BFS)
  6. c语言_文件操作_FILE结构体解释_涉及对操作系统文件FCB操作的解释_
  7. (转)PHP中extract()函数的妙用
  8. Cocos2d-x项目总结中的一些遇到的问题
  9. 为什么我最终替换掉了NATS
  10. 详解Swing中JTree组件的功能
  11. NYOJ--714--Card Trick
  12. 【ASP.NET MVC 学习笔记】- 19 REST和RESTful Web API
  13. web开发-Django博客系统
  14. deb包转化为rpm包
  15. admin 自定义字段颜色 并加以简单判断
  16. createrepo命令
  17. Java中通过脚本引擎调用js函数
  18. Kruskal和prime算法的类实现,图的遍历BFS算法。
  19. JS设计模式(2)策略模式
  20. 国内高速Maven仓库

热门文章

  1. Docker容器可以使用容器平台管理自动重启实现自修复吗?
  2. Chrome好用的插件:Wappalyzer 检测网站使用的技术
  3. LA 3295 数三角形
  4. POJ 2186 Popular Cows(强连通分量Kosaraju)
  5. 面试笔试总结(一)之 C++基础
  6. vim与shell切换
  7. js事件在不同浏览器之间的差异
  8. java网络编程之图片上传
  9. [nodejs]国内npm安装nodejs modules失败的几个解决方案
  10. nyoj744——异或(sb题)