find a location for property in a new city

Thursday, 27 May 2010

MVC2 deploy - Could not load file or assembly 'System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

A new MVC 2 project worked on my local machine but when it was deployed to the test server it gave the error 'Could not load file or assembly 'System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.' I have the full Visual Studio 2010 installed on my local machine but just the .NET 4 framework installed on the test servers. It seems the MVC assemblies do not come with .NET 4 framework itself so how to make MVC 2 work on the test servers?

Update This was written for difficulties with deploying an MVC 2 app. I have written a new blog post about deploying an ASP.NET MVC 3 web application to keep you up to date with the new technologies.

When I installed Visual Studio 2010 on my local machine it came with all the fruit included (.NET4 framework, MVC2 etc) so the System.Web.Mvc.dll can be found in my machine's GAC (C:\Windows\assembly). However, since there is no need to bloat the web servers only the plain old .NET4 framework has been installed on the test servers. This does NOT include the MVC assembly and that is why it cannot be found by the web application.

You need this assembly to be on your web servers that you are deploying to but you want to avoid having to copy them into the GAC manually and doing all that gacutil mess or maybe you don't have access to your servers if they are hosted by godaddy or something.


You need to make the System.Web.Mvc assembly bin deployable... okay that doesn't sound easy but here is how to do it for the necessary MVC references:

Simply right click the reference and select 'Properties':

Then change 'Copy Local' to 'True':


If your server has .NET 3.5 sp1 installed the new(ish) assemblies System.Web.Routing and System.Web.Abstractions will already be in the GAC. If you had previously deployed an MVC 1 application to a .NET 3.5 server you may remember having to deploy the other two assemblies too. Since MVC2 requires at least .NET 3.5 sp1 you will not need to worry about these assemblies, just System.Web.Mvc.


There is an easier way to do this if you are using Visual Studio 2010 Service Pack 1 and using Web Deploy as your publish action when publishing. You can add deployable dependencies to your ASP.NET MVC project that will choose the necessary assemblies for you. Even easier!

Follow britishdev on Twitter


  1. Thanks for the explanation. I was really struggling to get my MVC 2 app deployed to IIS 6 and didn't know if the server wasn't properly configured or if it was a deployment issue.

  2. Thanks! Deployed .net 3.5 project to GoDaddy; had to change that setting only for System.Web.Mvc.

  3. Works great, thx

  4. thanks for your valuable tip and was able to launch my mvc app however the images and js queries doestn seem to b working.

    i read in that

    HttpContext.Current.RewritePath(Request.ApplicationPath); has to b changed to
    HttpContext.Current.RewritePath(Request.ApplicationPath, false);

    m not sure where do i change this..pls help

  5. Looks like he's talking about the default.aspx.cs in the IIS root. It was put their by IIS itself

  6. Tried to deploy my first ASP.NET MVC website to my VPS, got the error 'Could not load file or assembly 'System.Web.Mvc'. Oh, i thought okay lets install .NET 4.0 Standalone my server, spent my life doing that releasing then that it didnt bloody solve the problem... at which point im seriously pi**ed off

    So i turned to goggle for 'Could not load file or assembly 'System.Web.Mvc', came to (2nd in goggle by the way, before, make System.Web.MVC bin deployable boom, problem solved.

    Im more annoyed that .NET 4.0 gave me the impression that it'd have MVC 2 innit.

  7. Thank you very much!! You saved my day.

  8. Very useful.

  9. Thanks from Barcelona.
    Very useful :)

  10. you kill my nightmares
    thank you from sheffield

  11. Here is a full tutorial explaining how to configure server and publish MVC2 application

  12. Because Aries is open-source, it is free and readily available to download. Aries has a user interface that is intuitive and easy to navigate, even for people who aren't computer whizzes. - shareit app for android

  13. I Will Provide Seo Blog Comment Service. & niche relevant blog comment service we provide a quality service with 100% Buyer satisfaction and My team Believed in Quality work not Quantity Contact me Now 24/7.

  14. If you read a review that does not come up with any negative comment, move on, because no product is without some problems, and Top Web Hosting Reviews you need to know what they are, so that you're prepared for any glitches. Namecheap SSL coupon

  15. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
    web hosting in Nigeria

  16. It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content. affordable seo

  17. Thanks for providing such a great Information, you can see, we also provide
    Peptide Synthesis

  18. Web application improvement at decreased expense is the key purpose behind associations to seaward their advancement work to India. Associations in Developed nations like U.S, U.K, Canada, Australia, Denmark, Sweden and so on think that its extravagant to create web
    Web Design Curriculum applications at their very own work environment due to high compensation.

  19. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. Digital marketing company

  20. I would like to say that this blog really convinced me to do it! Thanks, very good post. Zerteck

  21. Them two turned out with their individual proposition for Hypertext frameworks and later on they joined together and offered joint proposition.Webdesign

  22. Thanks for the valuable information and insights you have so provided here.

    192.168 l 254

  23. It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. best web hosting