When deploying an MVC application to a hosting environment you may receive the error:

[FileNotFoundException: Could not load file or assembly ‘Microsoft.Web.Infrastructure, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.]

This is also one of a few component libraries that are needed for deploying an MVC application:

  • System.Web.Helpers.dll (required by the web.config)
  • System.Web.Mvc.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll
  • Microsoft.Web.Infrastructure.dll

The system libraries are installed with .NET 4, however, ‘Microsoft.Web.Infrastructure.dll’ is only installed when Visual Studio is installed on the machine.  Therefore, short of needing to install MVC and Visual Studio on a production environment, we need to deploy the libraries with out application – and we’d like to do so automatically.

There are a few ways to automatically deploy the ‘Microsoft.Web.Infrastructure.dll’ component library with your application.  The steps depend on which version of Visual Studio you are using.

Visual Studio 2010

Right-click on your project and select “Add Deployable Assemblies” and you’ll see the following dialog:


When deploying for MVC, only choose the first option.  Never mind the second option even though it says “Razor syntax.” The second option is for deploying the required libraries for projects officially known today as ASP.NET Web Pages. Once you click OK, you’ll see a new folder appear in your project called _bin_deployableAssemblies with the required libraries.


For .NET, this is a special folder:

  1. This is a secondary bin folder for framework dependencies.  If you right-click on any one of the .dll’s shown in this folder, you’ll see that the libraries are set to “Copy to Output Directory”.  When the application is packaged/deployed, the libraries (and the folder) are also copied.  Again, the framework will also automatically check this folder for dependencies.
  2. For .NET, any folder that begins with an underscore (“_”) is considered private and non-accessible to the browser.  Therefore, you can rest knowing that the dependencies are secure.

Note that this process did not add any references to these libraries in your project.  They are simply here for the framework to run your MVC application.  If you do, in fact, need a type or class from one of these libraries, you are free to still add it as a reference as you normally would.

Visual Studio 2012+

After Visual Studio 2010, the “Add Deployable Assemblies” option was removed from the project’s options menu.  The system libraries are automatically copied to the Bin folder of your project. However, again, the ‘Microsoft.Web.Infrastructure.dll’ is only available on machines that have Visual Studio installed.  So how do you deploy this library with you application if you don’t want to install Visual Studio on a production environment?  I’m glad you asked.  You’ll need to use the Package Manager.

  1. Run the following command in the package manager (if you’re not familiar with Visual Studio, this can be reached by going to “Tools –> Library Package Manager –> Package Manager Console” in the top menu).
  2. At the PM> prompt type:
    Install-Package Microsoft.Web.Infrastructure

    You will see then see a message indicating that it has been installed and added to your project.

  3. You’ll also see that ‘Microsoft.Web.Infrastructure.dll’ has been added as a reference in your References folder.
  4. Finally, now, when you deploy your application, ‘Microsoft.Web.Infrastructure.dll’ will be included in the Bin folder.