0

I have a Visual Studio solution with many projects - one is a legacy Web Forms project.

On the deployed server there is no system.web.webpage.razor.dll - but in the local version it's there, and it's the wrong version (it's looking for 2.0.0.0 and it's 3.something).

If I just delete it - it comes back when I build the solution. It seems like this dll isn't required for the site to function as it's not on the deployed version on the sever.

What is causing this to keep being re-added? It's not referenced in Web.config and I've done a text search of the project and there are no references to it anywhere.

The version conflict is causing problems - and it seems like it doesn't even need to be there?!

Primarily I'd like to find and remove the cause of it being re-added - secondarily I'd like to know how I can fix the version (is there a nuget package that contains this dll?) Thanks.

I can't find a solution to either on Google.

Update - stack trace:

Server Error in '/MyApp' Application. Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 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.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:

[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Mvc.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures) +850
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +162
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +128
System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +820

[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +523
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3056.0

niico
  • 11,206
  • 23
  • 78
  • 161
  • One of the assemblies could dependent on this dll. What error are u getting? Maybe this could help: https://stackoverflow.com/questions/11000506/could-not-load-file-or-assembly-system-web-webpages-razor-version-2-0-0-0 – Curly Brace May 13 '18 at 12:39
  • Thanks - I'd seen that - I don't appear to have a dependent assembly - not sure how to work this problem... – niico May 13 '18 at 14:18
  • I just saw a video where the guy right-clicked his solution (i couldn't tell what kind of solution it is) and he had the option to 'Clean', and it was fixed. Any chance you have that? Or maybe rebuild solution instead of build? – wazz May 16 '18 at 06:49
  • There is a nuget package. It looks like you can upgrade what you have or browse for microsoft.aspnet.webpages (for me, razor was right underneath). Btw, I just searched for `System.Web.WebPages.Razor, Version=2.0.0.0` and got over 10,000 hits, mostly with the same error or similar. – wazz May 16 '18 at 06:59
  • I did see other articles about it - but none fixed the issue. I tried cleaning and rebuilding - no help. – niico May 18 '18 at 12:26

0 Answers0