Deploying MVC 3 Razor – Bin issues

The current application I’m working on requires me to publish an MVC 3 Razor web application.  I’m using sFTP as the protocol to my hosting provider.  After the first publish I was unable to run the application.   It kept throwing errors that I was missing assemblies.    The first error I got was that the application was missing the Microsoft.Web.Infrastructure.dll.   I added that DLL into the references and set it to copy local.  Knowing that the copy local would allow me to publish the dll into the applications Bin directory.

This worked for only that DLL.  I then got anther error of another missing dll: System.Web.Mvc.dll.   After this I did a few searches to see what the issue was.  I noticed a few posts mentioning these issues when the hosting provider did not MVC installed.    To get around this there are a few suggestions.    I read Hanselman’s post regarding bin publishing.

At first I added a folder in the bin directory called _bin_assemblies.  I added the following DLL’s. (you can get them as a zip file here)

  • System.Web.Mvc
  • Microsoft.Web.Infrastructure
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Razor
However in Visual studio SP1 they fixed this issue. You can right click on your project and select Add Deployable Dependencies.  You get a box  to select what to include.
This will allow your deployment to include the necessary dependencies.   A special folder named _bin_deployableAssemblies is created and the necessary assemblies are copied into this folder. Web projects have a built in build process that copies the assemblies from this folder into the bin folder when compiled.

Leave a Comment