C# 无法加载文件或程序集“System.Web.WebPages.Razor,版本=3.0.0.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19763039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0
提问by Hamid Bahmanabady
I want using external logins so I installed Oauth by package manager:
我想使用外部登录,所以我通过包管理器安装了 Oauth:
PM> Install-Package Microsoft.AspNet.WebPages.OAuth
Then I got this error after installed it then I install razor:
然后我在安装后收到这个错误然后我安装了剃刀:
PM> Install-Package Microsoft.AspNet.Razor
But I still have this exception. Further more my application is an asp.net application and not a MVC application. Thanks for help.
但我仍然有这个例外。此外,我的应用程序是一个 asp.net 应用程序,而不是一个 MVC 应用程序。感谢帮助。
[FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0
采纳答案by Anirudha Gupta
You have upgraded to Razor 3. Remember that VS 12 (until update 4) doesn't support it. Install The Razor 3 from nuget or downgrade it through these step
您已升级到 Razor 3。请记住,VS 12(直到更新 4)不支持它。从 nuget 安装 Razor 3 或通过这些步骤将其降级
geekswithblogs.net/anirugu/archive/2013/11/04/how-to-downgrade-razor-3-and-fix-the-issue-that.aspx
geekswithblogs.net/anirugu/archive/2013/11/04/how-to-downgrade-razor-3-and-fix-the-issue-that.aspx
回答by Jeffrey Roughgarden
Apologies in advance for this lo-tech suggestion, but another option, which finally worked for me after battling NuGet for several hours, is to re-create a new empty project, Web API in my case, and just copy the guts of your old, now-broken project into the new one. Took me about 15 minutes.
提前为这个 lo-tech 建议道歉,但另一个选择,在与 NuGet 战斗了几个小时后终于对我有用,是重新创建一个新的空项目,在我的例子中是 Web API,然后复制你旧的内容,现在已经破的项目变成了新的项目。花了我大约 15 分钟。
回答by Ga?per Sladi?
Another option is to update the Microsoft.AspnNet.Mvc NuGet package. Be careful, because NuGet update does not update the Web.Config. You should update all previous version numbers to updated number. For example if you update from asp.net MVC 4.0.0.0 to 5.0.0.0, then this should be replaced in the Web.Config:
另一种选择是更新 Microsoft.AspnNet.Mvc NuGet 包。小心,因为 NuGet 更新不会更新 Web.Config。您应该将所有以前的版本号更新为更新后的编号。例如,如果您从 asp.net MVC 4.0.0.0 更新到 5.0.0.0,则应在 Web.Config 中替换它:
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
回答by Imamul Karim Tonmoy
Update using NuGet Package Manager Console in Visual Studio
在 Visual Studio 中使用 NuGet 包管理器控制台进行更新
Update-Package -reinstall Microsoft.AspNet.Mvc
更新包-重新安装 Microsoft.AspNet.Mvc