Thursday, April 26, 2012

"Add Deployable Dependencies" option in Visual Studio 2010 When you want to deploy ASP.NET MVC application


I would like to share this option for the developer who are using Visual studio 2010 for development and working on ASP.NET MVC application. When you try to host your application (ASP.NET MVC) on window server and if you server haven't installed MVC then you might be get following type of error.

Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified



This is because of your web server doesn't have installed MVC. I have faced same issue in my case and tried to search around the web and found some good articles as per below.
Conclusion of above posts is to add MVC related dlls(As listed below) change it's property Copy Local="true" to run your ASP.NET MVC on web server where MVC is not installed.
  •     Microsoft.Web.Infrastructure
  •     System.Web.Helpers
  •     System.Web.Mvc
  •     System.Web.Razor
  •     System.Web.WebPages
  •     System.Web.WebPages.Deployment
  •     System.Web.WebPages.Razor
Now the question is from where you get all these dlls? This question help me to find this "Add Deployable Dependencies" option in Visual Studio 2010.
You can find the above dlls from this location C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies

OR In Visual studio right click on your project and click "Add Deployable Dependencies" and it will prompt for which one you want to add, and select ASP.NET MVC as shown in below figs.



It will add all required dlls in _bin_deployableAssemblies folder and when you build this project you can find this dlls in /bin directory of your project so your application will work on Window server without installed MVC.

Another way you can do it in Window AZURE
Also i found good article by smarx >> ASP.NET MVC 3 in Windows Azure when i was searching to run ASP.NEt MVC application in window Azure.
In this article he has talked about how you can install MVC in window azure instance by startup task.

Finally got my application working! Happy Programming!!

No comments: