0

I deployed my code to server and I am facing error

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 located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Stack Trace:

[FileLoadException: 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 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=3.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(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +646
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +147
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +107
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +165
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +590
[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=3.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) +10080656
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

Any idea how to solve this error . Please help .

Sathish Guru V
  • 1,417
  • 2
  • 15
  • 39
Maximious
  • 155
  • 2
  • 12
  • Is it copy local set true? compiled in x86 while some of the dependencys were compiled in x64? – Mertuarez Apr 09 '20 at 08:25
  • Please add more details and always post with a minimal reproducible example to help you https://stackoverflow.com/help/minimal-reproducible-example – Sathish Guru V Apr 09 '20 at 08:26
  • "definition does not match the assembly reference" This tell me that it could find the assembly but not the correct version of the assembly, you could use a rebind to force the application to load the version you have. Can you check what version is currently in your bin folder? – Martin Venter Apr 09 '20 at 08:28
  • that's the thing I don't have any code for this project . I just uploaded via file zilla – Maximious Apr 09 '20 at 08:29
  • @MartinVenter I checked the file version is 2.0.20710.0 in my bin folder – Maximious Apr 09 '20 at 08:32
  • @Maximious If you don't have any code you could try to change the dependentAssembly binding in the web.config file to force the application to use the version you have see this link https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/assemblybinding-element-for-runtime (There might be breaking changes between these version) – Martin Venter Apr 09 '20 at 08:35
  • 1)Open the Package Manager Console 2)Tools > NuGet Package Manager > Package Manager Console 3)Change the package source to Microsoft and .Net. 4)Change the project to the one you are debugging. 5) Run the following command. Update-Package Microsoft.AspNet.Mvc -Reinstall [link](https://stackoverflow.com/questions/46396243/could-not-load-file-or-assembly-system-web-webpages-razor-version-3-0-0-0-cul) – Jalpa Panchal Apr 10 '20 at 08:20
  • @JalpaPanchal he mentioned that he doesn't have any code for this project – Martin Venter Apr 11 '20 at 05:58

0 Answers0