Could not load file or assembly 'Microsoft.Web.Infrastructure,

后端 未结 20 2087
走了就别回头了
走了就别回头了 2020-12-09 00:57

I tried to upload my web site to a server. It was working fine with my local host, so I uploaded everything in my localhost wwwroot folder to the server and cha

20条回答
  •  执念已碎
    2020-12-09 01:22

    Here was my scenario.

    I had a multi project solution containing projects A, B, C .. N.

    Project B was a code library that contained a factory for selectlist objects.

    The project would run as expected in development, but when publishing to our test environment I was getting the error you were encountering:

    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.
    

    What had happened was through nuget package manager, I had accidentally installed "Microsoft ASP.NET MVC" which installed dependencies for:

    • Microsoft.AspNet.Razor
    • Microsoft.AspNet.WebPages

    Low and behold, Microsoft.AspNet.WebPages depends on "Microsoft.Web.Infrastructure".

    My solution was uninstalling the three packages mentioned above (MVC, Razor, WebPages) then right click references > add reference > Assemblies > Extensions > System.Web.MVC.

提交回复
热议问题