Could not load file or assembly System.Web.Mvc

时间秒杀一切 提交于 2019-12-03 22:29:28

We're using Azure cloud to run a deployment and I got the same error. Since you can't really install packages onto the server instances, the way to solve this is to go into References for your project, find the reference to the library that it's complaining is missing, go into properties, then set Copy Local to True. Redeploy and you're all set.

I'm assuming this is a new machine, seeing as you have the new OS and different version of Visual Studio. I think you need to install MVC Framework version 2, as that's what your Umbraco install is expecting. You can either install the Framework, and get the DLLs into your GAC, or copy the DLLs from your good system to the bin folder of your web application.

Note, you're saying your project "doesn't use" MVC, but I think you'll find Umbraco does. The error, at any rate, is telling you that the system expects to find it.

The correct fix for this issue is to:

  1. Right-click on References in your Solution Explorer and choose Manage NuGet Packages
  2. On the left side select Updates
  3. In the middle section select Microsoft ASP.NET MVC
  4. You should see an Update button appear in your selection, click on it

That's it...accept any T&Cs that might pop-up and either publish or run your project locally. If you're still having problems running your project locally, try closing Visual Studio deleting the .SUO file for the project and try opening the solution again...try running again.

Umbraco 4.11.3 doesn't use MVC2, it uses MVC3 so I would guess that you have a reference in your web.config to the MVC2 library, possibly in the compilation > assemblies section. It should look something like this:

<compilation defaultLanguage="c#" batch="false" targetFramework="4.0" debug="true">
  <assemblies>
    <!-- ASP.NET 4.0 Assemblies -->
    <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </assemblies>
  <!-- Added in Umbraco 4.6.2 -->
  <buildProviders>
    <add extension=".cshtml" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines" />
    <add extension=".vbhtml" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines" />
    <add extension=".razor" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines" />
  </buildProviders>
  <!-- End of added in Umbraco 4.6.2 -->
</compilation>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!