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

后端 未结 20 2015
走了就别回头了
走了就别回头了 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:16

    I had this problem. I had the DLL included into the project and the setting to Copy Local was true by default. Don't know why it started, since that DLL was in the project for a long while. I've heard some mentions of ReSharper possibly removing it, but I can't say I've ran a unused reference removal.

    What helped me was: - Running "Update-Package Microsoft.Web.Infrastructure -Reinstall" on the project, which updated the whole solution, but didn't end up helping in and of itself. - Then I went through the projects' references and set the Copy Local to false, and then back to true. This actually resulted in a line being added into CSPROJ file under the DLL reference: True. Or something along the lines... Either way, now the build was copying the files as expected.

    0 讨论(0)
  • 2020-12-09 01:17

    I found that even though it worked on my dev box, the assembly wasn't added to the project. Search for Microsoft.Web.Infrastructure in NuGet and install it from there. Then, make sure it has Copy Local selected.

    0 讨论(0)
  • 2020-12-09 01:17

    So, here's what worked for me using VS2019. I was getting this error trying to update Nuget packages on one project while the Microsoft.Web.Infrastructure was in a different project in the same solution. I had to delete the Microsoft.Web.Infrastructure.1.0.0.0 folder from my project's Packages folder. Reinstalled it via nuget and then everything started working again. Crazy stuff.

    0 讨论(0)
  • 2020-12-09 01:22

    Very easy solution:

    In Visual Studio, go to Tools/Library Package Manager/Package Manager Console

    <PM> Install-Package Microsoft.Web.InfraStructure
    

    Have a nice time

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-09 01:23

    Experienced this issue on new Windows 10 machine on VS2015 with an existing project. Package Manager 3.4.4. Restore packages enabled.

    The restore doesn't seem to work completely. Had to run the following on the Package Manager Command line

    Update-Package -ProjectName "YourProjectName" -Id Microsoft.Web.Infrastructure -Reinstall
    

    This made the following changes to my solution file which the restore did NOT do.

    <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
      <Private>True</Private>
    </Reference>
    

    Just adding the above elements to the ItemGroup section in you solution file will ALSO solve the issue provided that ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll exist.

    Easier to just do the -Reinstall but good to understand what it does differently to the package restore.

    0 讨论(0)
提交回复
热议问题