Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are all of the ASP.NET MVC 4 RC assemblies really necessary for a ASP.NET WebAPI RC deployment?

When I created a "Empty WebAPI" project in Visual Studio 2010, several of the new assemblies to support the MVC web pages were added as references (an example of the few in the list below):

  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll

For the sake of cleanliness, I removed those DLL references that I wasn't using (or so I thought I wasn't "using"). When deploying to the server I would get exceptions like the following:

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

I am currently doing a bin deploy to the server with all of the assemblies it took until the JIT compliation errors ceased.

I understand the FileNotFoundException. I understand that the runtime is trying to resolve that reference.

My question(s): Why is it necessary to carry around the MVC Razor assemblies when all you are trying to create is a WebAPI site? Is there another dependency that needs to be removed?

like image 919
Thomas Bates Avatar asked Jul 03 '12 23:07

Thomas Bates


1 Answers

No, you don't need all those assemblies.

I always prefer to build my Web API projects from scratch. I don't use the templates. I simply create an empty ASP.NET Project and add the Microsoft.AspNet.WebApi NuGet package.

Here are the references that seem to only be needed:

Microsoft.CSharp
Microsoft.Web.Infrastructure   // Microsoft.Web.Infrastructure NuGet package
Newtonsoft.Json                // Newtonsoft.Json NuGet package
System.Net.Http                // Microsoft.Net.Http NuGet package
System.Net.Http.Formatting     // Microsoft.AspNet.WebApi.Client NuGet package
System.Net.Http.WebRequest     // Microsoft.Net.Http NuGet package
System.Web.DynamicData
System.Web.Entity
System.Web.ApplicationServices
System.ComponentModel.DataAnnotations
System
System.Data
System.Core
System.Data.DataSetExtensions
System.Web.Extensions
System.Web.Http                // Microsoft.AspNet.WebApi.Core NuGet package
System.Web.Http.WebHost        // Microsoft.AspNet.WebApi.WebHost NuGet package
System.Xml.Linq
System.Drawing
System.Web
System.Xml
System.Configuration
System.Web.Services
System.EnterpriseServices
like image 83
Bertrand Marron Avatar answered Oct 28 '22 01:10

Bertrand Marron