Server error / application with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure after changing to MVC5

0

Recently we have updated MVC4 to MVC5. I have a webservice which used for reporting purpose when i launch the webservice i got the below errors

[FileNotFoundException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.WebPages.PreApplicationStartCode.Start() +0
   System.Web.Mvc.PreApplicationStartCode.Start() +37

[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 'Microsoft.Web.Infrastructure, Version=1.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) +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 'Microsoft.Web.Infrastructure, Version=1.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) +523
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688

i have not referenced this Microsoft.Web.Infrastructure.dll in my service but after upgrading to MVC5 got this dll issue. Any help?

c#
asp.net
asp.net-mvc
dll
asp.net-mvc-5
asked on Stack Overflow Sep 17, 2020 by saravana

1 Answer

0

Microsoft.Web.Infrastructure.dll is key library. You should add this one may be this one required / referenced internally.
You can check all dll ref in packages.config file and web.config

Or it may be present at local but you didn't make it Copy Local to True in it's properties

answered on Stack Overflow Sep 18, 2020 by Vikas Bhukar

User contributions licensed under CC BY-SA 3.0