asp.net-mvc-3 - ASP.NET MVC 3 RTM 项目中的这个错误是什么?

标签 asp.net-mvc-3

我创建新项目 ASP.NET MVC 3 RTM 并替换引用
使用 ASP.NET MVC 3 源代码

但是当我再次运行项目时,得到这个异常:

[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\2505c7ee\369315c5\assembly\dl3\f7bae428\d03eeed8_85bbcb01\System.Web.WebPages.Razor.DLL'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



源错误:
Line 106:        internal static RazorWebSectionGroup GetRazorSection(string virtualPath) {
Line 107:            // Get the individual sections (we can only use GetSection in medium trust) and then reconstruct the section group
Line 108:            return new RazorWebSectionGroup() {
Line 109:                Host = (HostSection)WebConfigurationManager.GetSection(HostSection.SectionName, virtualPath),
Line 110:                Pages = (RazorPagesSection)WebConfigurationManager.GetSection(RazorPagesSection.SectionName, virtualPath)

Source File: E:\GreenTour\webpages\src\System.Web.WebPages.Razor\WebRazorHostFactory.cs Line: 108

最佳答案

此错误意味着您的应用程序的一部分正在使用您自己的源代码副本作为引用进行编译,而在运行时它会在 GAC 中查找引用程序集。确保删除对 MVC 3 程序集的 GAC 版本的所有引用。这包括 web.config 文件中使用此公钥 token 的许多内容:31bf3856ad364e35。

关于asp.net-mvc-3 - ASP.NET MVC 3 RTM 项目中的这个错误是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4781586/

相关文章:

asp.net-mvc-3 - 使用 EditorFor/TextBoxFor/TextBox 帮助器在名称中带有破折号的自定义属性

ASP.NET MVC 3 Razor 页面中的 JavaScript

mysql - 让appharbor与现有的mysql服务器一起工作

Jquery Validation 在第一个字符是小数的数字字段上有一个严重的错误

asp.net-mvc-3 - 具有共享布局的 ASP.NET MVC 区域

c# - mvc3 Razor 中的复选框列表示例,

asp.net - 覆盖实体的删除

asp.net-mvc-3 - 通过 Ajax 在 ASP.NET MVC3 中上传文件不起作用

asp.net-mvc - 实现 "Down for maintenance"页面

asp.net-mvc-3 - 如何在MVC3中将数据绑定(bind)到Grid?