Deployment of new web applications has been a bit annoying since the birth of ASP.NET MVC. Production servers with .NET 4 or 3.5 installed will still be missing key assemblies such as System.Web.Mvc.dll. This will cause errors such as "Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies" and "Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies." when your project is deployed to production.
It is confusing for two reasons: Why does it work on your development machine? Well, when you install all the tools required to make MVC application you get all the necessary assemblies with it. Which assemblies are your production servers missing? Well there were 3 in ASP.NET 1, 1 in ASP.NET MVC 2 but now with ASP.NET MVC 3 + Razor there are loads. I've found out which ones I actually need before but it is still confusing.
With Visual Studio 2010 SP1 there is a new feature that does all the hard work for you. You can right click your ASP.NET MVC web application project and select 'Add Deployable Dependencies...':
Then you select the type of features you are using so Visual Studio can decide which references are needed:
It will then create a _bin_deployableAssemblies directory for you with all the assemblies included:
Now if you publish using Web Deploy it will include those files as expected and your deployed solution will be happy once more.
Important note:
If you are not using the 'Web Deploy' as your publish method though - this will NOT work. You will need to reference the assemblies and make them bin deployable yourself.
TeXShop MakeIndex with style file
3 months ago






Thank you! This little bit of info: If you are not using the 'Web Deploy' as your publish method though - this will NOT work. You will need to reference the assemblies and make them bin deployable yourself. Saved me tons of head ache.
ReplyDeleteThank you, thank you, ...
ReplyDeleteFYI...the WebMatrix assemblies break your app when using Windows authentication.
ReplyDeleteInteresting. Thanks for the info
DeleteThis comment has been removed by the author.
DeleteI guess that's why I suddenly had to add some appSettings to my Web.config for my forms authentication to work:
Delete<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false"/>
Any thoughts on "bin deploying" in 2012? I understand "Add Deployable Dependencies" is not available in vs2012.
ReplyDelete