I tinkered with my ASP.NET MVC4 packages via NuGet, and now System.Web.WebPages.Razor v3
won't load. Sometimes other packages won't load either.
My coworker runs the solution without any trouble, so the issue is definitely configuration on my development system (as opposed to anything that's been checked in).
I have already tried the recommendations at various SOf and other fora links, including:
- Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0,
- Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0
- Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0
As well as suggestions linked from there. I also checked the Control Panel and found no installed programs that referenced MVC. (If it matters, I'm running MS Win 7 SP 1.)
I am open to any and all suggestions.
Here's my core dump info:
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
(For those who read this far: I don't have enough reputation to make the tag pulling-out-my-hair. If there's an appropriate extant tag, please include that. KTHX.)
ETA: When I tried manually updating Microsoft.AspNet.Mvc
to version 3, here's the error I got on Package Manager Console:
Install failed. Rolling back... Install-Package : Updating 'Microsoft.AspNet.Mvc 5.0.0' to 'Microsoft.AspNet.Mvc 3.0.20105.1' failed. Unable to find a version of 'Microsoft.AspNet.Mvc.FixedDisplayModes' that is compatible wi th 'Microsoft.AspNet.Mvc 3.0.20105.1'. At line:1 char:16 + Install-Package <<<< Microsoft.AspNet.Mvc -Version 3.0.20105.1 + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
ETA2: I got the packages directory from my coworker. They have MS.AspNet.Mvc
v5, and they're running just fine. But they ALSO have MS.AspNet.Mvc.FixedDisplayModes
v5. So I'm going to add both of those in. And yes, I have backed up my entire solution. :)
ETA3: So I re-upgraded to AspNet MVC v5, and skipped the deprecated Mvc.FixedDisplayNodes. Then I got a problem with conflicting versions of AspNet.WebPages, so I used this fix: Conflicting versions of ASP.NET Web Pages detected: specified version is "1.0.0.0", but the version in bin is "2.0.0.0" in ASP.MET MVC 3
And now my project runs!
Thanks all for the help!
"Update-Package –reinstall Microsoft.AspNet.WebPages"
Reinstall Microsoft.AspNet.WebPages nuget packages using this command in the package manager console. 100% work!!
in the new actionmailer, "razorengine" is a dependency. The latest version of Razorengine installs the dependency to System.Web.Razor 3.0.0.
If you use an earlier version in your application (i suppose you are using actionmailer in another project and that you reference the mail functionality from another project) than you get this issue of course.
In an earlier application, i had a webapplication MVC that uses system.web.Razor version 2.0.0. Of course, i got the issue to. How to fix? => Simple!
I did not want to install visual studio and development environment, so I have installed AspNetMVC4Setup.exe in Windows server 2016 machine and it solved the problem. The installer was downloaded from Microsoft website.
In my case the issue didn't resolve by following any of the above methods. I had all the paths in my package config correct and the dll's were in place as referred, I was still getting run time error for System.Web.WebPages.Razor.
I changed the localhost port number and this worked
I am not sure of why I had the issue and why changing the port number resolved it. Just posting this as I feel this might be useful for someone out there.
Is there a System.Web.WebPages.Razor.dll in the bin folder of your web app? What is its version? (Explorer right click, properties) I'm guessing it's not 3.0.0.0. Just get the nuget packages for v3.0.0.0, perhaps by copying the packages folder from your colleague. Or install it manually: http://www.nuget.org/packages/Microsoft.AspNet.Mvc/3.0.20105.1
EDIT: if you copy stuff from your colleague, also copy the relevant version numbers into packages.config. This is what tells nuget which versions to put into the packages folder.
same thing JUST happened to me with NUGET.
the following tag helped
Also if this is happening on the server, I had to make sure I was running the application pool on a more "privileged account" to the file system, but I don think that's your issue here