我通过NuGet调整了我的ASP.NET MVC4包,现在System.Web.WebPages.Razor v3
无法加载。有时其他包也无法加载。
我的同事可以毫无问题地运行该解决方案,因此问题肯定是出现在我的开发系统配置上(而不是已经检入的任何内容)。
我已经尝试了各种SOf和其他论坛链接中的建议,包括:
- 无法加载文件或程序集“System.Web.WebPages.Razor,版本=2.0.0.0,”
- 无法加载文件或程序集“System.Web.WebPages.Razor,版本=2.0.0.0”
- 无法加载文件或程序集“System.Web.WebPages.Razor,版本=3.0.0.0”
此外,还有从那里链接的建议。我还检查了控制面板,没有安装引用MVC的程序。(如果重要的话,我正在运行MS Win 7 SP 1)。
我接受所有建议。
以下是我的核心转储信息:
(针对那些阅读到这里的人:我没有足够的声望来制作标签 pulling-out-my-hair 。如果有适当的现有标签,请包含在内。KTHX。)Server Error in '/' Application.
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.
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.
Exception Details: System.IO.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.
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information === LOG: User = CodesWithHammer LOG: DisplayName = System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase = file:///c:/users/CodesWithHammer/documents/visual studio 2012/Projects/MPP/MPP/ LOG: Initial PrivatePath = c:\users\CodesWithHammer\documents\visual studio 2012\Projects\MPP\MPP\bin Calling assembly : Microsoft.Web.WebPages.OAuth, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
=== LOG: This bind starts in default load context. LOG: Using application configuration file: c:\users\CodesWithHammer\documents\visual studio 2012\Projects\MPP\MPP\web.config LOG: Using host configuration file: C:\Users\CodesWithHammer\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor.DLL. LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL. LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio 2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor.DLL. LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio 2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL. LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor.EXE. LOG: Attempting download of new URL file:///C:/Users/CodesWithHammer/AppData/Local/Temp/Temporary ASP.NET Files/root/5bf3ca07/f960d9c5/System.Web.WebPages.Razor/System.Web.WebPages.Razor.EXE. LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio 2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor.EXE. LOG: Attempting download of new URL file:///c:/users/CodesWithHammer/documents/visual studio 2012/Projects/MPP/MPP/bin/System.Web.WebPages.Razor/System.Web.WebPages.Razor.EXE.
Stack Trace:
[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
[InvalidOperationException: The pre-application start initialization method Start on type
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: 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..] System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection
1 methods, Func
1 setHostingEnvironmentCultures) +550 System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90 System.Web.Compilation.BuildManager.ExecutePreAppStart() +135 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): The pre-application start initialization method Start on type
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: 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..] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874840 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055
注:当我尝试手动更新
Microsoft.AspNet.Mvc 到版本3时,在Package Manager Console中出现以下错误:
安装失败。回滚... Install-Package:更新'Microsoft.AspNet.Mvc 5.0.0'到'Microsoft.AspNet.Mvc 3.0.20105.1'失败。无法找到与'Microsoft.AspNet.Mvc 3.0.20105.1'兼容的'Microsoft.AspNet.Mvc.FixedDisplayModes'版本。 在第1行第16个字符处: + Install-Package <<<< Microsoft.AspNet.Mvc -Version 3.0.20105.1 + CategoryInfo:NotSpecified:(:) [Install-Package],InvalidOperationException + FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
ETA2:我从我的同事那里得到了包目录。他们有“MS.AspNet.Mvc”v5,并且运行良好。但是他们还有“MS.AspNet.Mvc.FixedDisplayModes”v5。所以我要添加这两个。是的,我已经备份了整个解决方案。 :)
ETA3:因此,我重新升级为AspNet MVC v5,并跳过了已弃用的Mvc.FixedDisplayNodes。然后,我遇到了AspNet.WebPages版本冲突的问题,所以我使用了这个解决方法:检测到ASP.NET Web Pages的版本冲突:指定版本为“1.0.0.0”,但bin中的版本为“2.0.0.0”在ASP.MET MVC 3中
现在我的项目可以运行了!
感谢所有人的帮助!
clean
命令清理解决方案,然后再进行rebuild
吗?问题可能是你通过 NuGet 从 MVC4 更新到了 MVC5。 - Stan