title: How can I get my Web API app to run again after upgrading to MVC 5 and Web API 2?
body: <p>I  upgraded my Web API app to the funkelnagelneu versions using this guidance:</p>
  
  <p><a href="http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2" rel="noreferrer">http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2</a></p>
  
  <p>However, after going through the steps (it seems all this should be automated, anyway),  I tried to run it and got, "<em>A project with an Output Type of Class Library cannot be started directly</em>"</p>
  
  <p>What in Sam Hills Brothers Coffee is going on here? Who said this was a class library? </p>
  
  <p>So I opened Project > Properties, and changed it (it <em>was</em> marked as "Class Library" for some reason - it either wasn't yesterday, or was and worked fine) to an Output Type of "Windows Application" ("Console Application" and "Class Library" being the only other options).</p>
  
  <p>Now it won't compile, complaining: "<em>Program 'c:\Platypus_Server_WebAPI\PlatypusServerWebAPI\PlatypusServerWebAPI\obj\Debug\PlatypusServerWebAPI.exe' does not contain a static 'Main' method suitable for an entry point...</em>"</p>
  
  <p>How can I get my Web API app back up and running in view of this quandary?</p>
  
  <h2>UPDATE</h2>
  
  <p>Looking in packages.config, two entries seem chin-scratch-worthy:</p>
  
  <pre><code>&lt;package id="Microsoft.AspNet.Providers" version="1.2" targetFramework="net40" /&gt;
  &lt;package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" /&gt;
  </code></pre>
  
  <p>All the others target net451. Could this be the problem? Should I remove these packages?</p>
  
  <h2>UPDATE 2</h2>
  
  <p>I tried to uninstall the Microsoft.Web.Infrastructure package (its description leads me to believe I don't need it; also, it has no dependencies) via the NuGet package manager, but it tells me, "<em>NuGet failed to install or uninstall the selected package in the following project(s). [mine]</em>"</p>
  
  <h2>UPDATE 3</h2>
  
  <p>I went through the steps in again, and found that I had missed one step. I had to change this entry in the Application web.config File :</p>
  
  <pre><code>&lt;dependentAssembly&gt;
      &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
      &lt;bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" /&gt;
  &lt;/dependentAssembly&gt;
  </code></pre>
  
  <p>(from "4.0.0.0" to "5.0.0.0")</p>
  
  <p>...but I still get the same result - it rebuilds/compiles, but won't run, with "<em>A project with an Output Type of Class Library cannot be started directly</em>"</p>
  
  <h2>UPDATE 4</h2>
  
  <p>Thinking about the err msg, that it can't directly open a class library, I thought, "Sure you can't/won't -- this is a web app, not a project. So I followed a hunch, closed the project, and reopened it as a website (instead of reopening a project).</p>
  
  <p>That has gotten me further, at least; now I see a YSOD:</p>
  
  <p><em>Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</em></p>
  
  <h2>UPDATE 5</h2>
  
  <p>Note: The project is now (after being opened as a web site) named "localhost_48614"</p>
  
  <p>And...there is no longer a "References" folder...?!?!?</p>
  
  <p>As to that YSOD I'm getting, the official instructions (<a href="http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2" rel="noreferrer">http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2</a>) said to do this, and I quote: </p>
  
  <p>"<em>Update all elements that contain “System.Web.WebPages.Razor”  from  version “2.0.0.0”  to<br>
  version“3.0.0.0”</em>."</p>
  
  <h2>UPDATE 6</h2>
  
  <p>When I select Tools > Library Package Manager > Manage NuGet Packages for Solution now, I get, "Operation failed. Unable to locate the solution directory. Please ensure that the solution has been saved."</p>
  
  <p>So I save it, and it saves it with this funky new name (C:\Users\clay\Documents\Visual Studio 2013\Projects\localhost_48614\localhost_48614.sln)</p>
  
  <p>I get the Yellow Strip of Enlightenment across the top of the NuGet Package Manager telling 
  me, "<em>Some NuGet packages are missing from this solution. Click to restore from your online 
  package sources.</em>"</p>
  
  <p>I do (click the "Restore" button, that is), and it downloads the missing packages ... I end up with the 30 packages. </p>
  
  <p>I try to run the app/site again, and ... the erstwhile YSOD becomes a compilation error:</p>
  
  <p><em>The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..</em>      </p>
  
  <p>Argghhhh!!! (and it's not even talk-like-a-pirate day).</p>
  
  <h2>UPDATE 7</h2>
  
  <p>I'm still curious about why Humpty Dumpty fell down and broke his crown (so to speak), but I finally threw in the towel and created a new project, copying-and-pasting code - and it works fine (VS 2013 and Web API, with REST methods called from a VS 2008, .NET 3.5 client app).</p>