153

I have an old ASP.NET MVC 2 project which I do not want to upgrade to MVC 3 or MVC 4. I am working on a new machine running Windows 8, Visual Studio 2012 and Visual Studio 2013. When I try to open the MVC 2 project in VS 2012 or VS 2013 I receive the error:

This project is incompatible with the current edition of Visual Studio

The project is then unloaded and grayed out in Solution Explorer. I do not want to install another copy of Visual Studio. How can I open an old MVC project in a new version of Visual Studio?

ahsteele
  • 25,470
  • 26
  • 131
  • 238
  • Why did you ask this question if you knew? – Brian White Nov 16 '12 at 20:51
  • 30
    @BrianWhite When I ran into this problem this morning I did a quick Google search and didn't come up with anything. Since I am familiar with how VS project files work I had a guess as to the cause and a potential solution. Once I verified that solution worked I wanted to share that knowledge. Based on Jeff's guidelines [it’s ok to ask and answer your own questions](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/). – ahsteele Nov 16 '12 at 20:59
  • 1
    Thanks, I didn't know that. There's a number of things I haven't posted because I didn't see anyone looking for it here. – Brian White Nov 19 '12 at 21:11
  • 8
    ahsteele, thanks for posting the solution. Answering one's own questions, when a solution is found, adds knowledge to the community. – pomarc Feb 13 '14 at 10:41

3 Answers3

291

Opening an unsupported MVC project in Visual Studio 2012 or Visual Studio 2013 is actually pretty easy to accomplish with two steps. In fact, as bytebender’s comment indicates, these same steps should apply to and work for MVC 1 projects. However, I haven’t tested them and therefore cannot guarantee that they do in fact work.

Assuming that you have not already done so step one is to download and install MVC 1, MVC 2 or MVC 3 (close Visual Studio before starting the installation).

Once you have the appropriate flavor of MVC installed the project will still not load in VS 2012. This is because ASP.NET MVC projects are a project subtype of the Web Application project type. This means that the project has additional add ins and features available to it when used within Visual Studio.

Both Visual Studio 2012 and Visual Studio 2013 are limited in their backwards compatibility with ASP.NET MVC and other project types. Unfortunately, installing the old MVC bits did not change that. Visual Studio 2012 is compatible with the ASP.NET MVC 3 and 4 project flavors. Visual Studio 2013 is compatible with MVC 4 and MVC 5.

To get the project to load you will have to modify the project file. To do so right click on the unloaded project and select Edit. Which will open the project file as an XML text file. Find the ProjectTypeGuids node which should look something like this:

<ProjectTypeGuids>
    {F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>

Remove the appropriate Project Guid from the list:

  • ASP.NET MVC 1: {603c0e0b-db56-11dc-be95-000d561079b0}
  • ASP.NET MVC 2: {F85E285D-A4E0-4152-9332-AB1D724D3325} (shown in example above)
  • ASP.NET MVC 3: {E53F8FEA-EAE0-44A6-8774-FFD645390401}
  • ASP.NET MVC 4: {E3E379DF-F4C6-4180-9B81-6769533ABE47}

With the appropriate GUID removed the ProjectTypeGuids should look similar to this:

<ProjectTypeGuids>
    {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>

Save the file and close the Visual Studio project file editor. Right click the project and select reload. If the project does not reload close and reopen Visual Studio. You should now be able to work with your old ASP.NET MVC project in your new version of Visual Studio.

One important thing to note is that after these modifications Visual Studio is not aware that this is an ASP.NET MVC project; therefore the project-specific features like "Add Controller, View etc." will not be present in menus.

Community
  • 1
  • 1
ahsteele
  • 25,470
  • 26
  • 131
  • 238
  • 11
    This works for MVC 1 as well. I wasn't able to reload after editing the project file. I had to close and reopen visual studio and then it was able to load the MVC 1 project. Thanks! +1 – bytebender Dec 03 '12 at 19:34
  • @bytebender thank you for confirming that the above works for MVC 1 projects! – ahsteele Dec 03 '12 at 20:44
  • 1
    excellent! works for me with one small addition... in my .cspproj I had an extra projectTypeGuid: {F85E285D-A4E0-4152-9332-AB1D724D3325}; which needed to be removed. – Kevin Won Mar 14 '13 at 19:51
  • There is an MVC2 - MVC3 upgrader application that can provide a more complete migration to VS 2012. I don't think it will work for MVC 1 applications. See my answer and link below. – Roland Schaer Mar 15 '13 at 13:58
  • 2
    @JookyDFW the problem with the migration utility is that *it is a migration utility*. For reasons not enumerated in the question for this particular project I couldn't upgrade from MVC 2. Even though the project couldn't be upgraded I still needed to work on it. Modifying the project file as outlined is the best (only?) way to work with an MVC 2 project in VS 2012. – ahsteele Apr 03 '13 at 20:56
  • @JoostSchepel thank you for confirming that. I assumed that it would, but had planned on firing up a VM to be sure. Now I don't have to. – ahsteele Jul 01 '13 at 13:55
  • 1
    Important point to note: You still need VS 2010 installed on the box to be able to open the project in VS 2012! This will not work on a machine with only VS 2012 installed. – Ryan Shripat Jul 10 '13 at 11:33
  • 3
    @RyanShripat that was not my experience at all. The older versions of ASP.NET MVC must be installed but VS 2010 has no affect on the above. – ahsteele Jul 10 '13 at 13:35
  • Relevant Information: After installing MVC 2, the template won't be visible under Add New Project tab. So no need to worry about that. You should still be able to open MVC 2 projects after making edits (Removing Guid's as mentioned above) to the proj/soln file. – Nanu Mar 13 '14 at 18:45
  • 2
    @Nanu thank you for the comment, to be clear that is what I meant by: "*One important thing to note is that after these modifications Visual Studio is not aware that this is an ASP.NET MVC project; therefore the project-specific features like "Add Controller, View etc." will not be present in menus.*" – ahsteele Mar 13 '14 at 19:12
  • @ahsteele - Did you ever find a way to get VS to offer the "Add controller, View" options? In VS 2013 on an MVC3 project all you get is MVC5 razor views and no controller options. My proj is MVC3 webforms. At present I have to open in VS2012 in order to add, save and then reopen in 2013, :( – Peter Jul 11 '14 at 11:37
  • @peter I didn't because there isn't a way to do so. Without the project type GUID Visual Studio has no way to know what the project type is, further even if it did VS2013 doesn't have the templates for your project type. That said the add controller, view etc. menu items just give you a template. It's more manual to add a regular class and appropriate using statements and inheritance, but not a ton of work. You could go so far as to add a custom snippet or template to handle this yourself. HTH – ahsteele Jul 11 '14 at 14:53
  • It's fine for adding the controllers but not for the aspx/ascx views and partials because it if you use the standard webforms it tries to create useless code behind. I wish MS wouldn't pull this crap, there is zero reason not to support this. Anyhow hopefully we'll be able to upgrade to MVC5 + razor view engine. – Peter Jul 14 '14 at 07:57
  • 1
    Absolute life saver - Iv'e inherited an old MVC app and couldn't get it running! – D3vy Jul 09 '15 at 13:38
  • This worked for me. In all of my VS 2010 projects, removing the {F85E285D-A4E0-4152-9332-AB1D724D3325} GUID resolved the compatibility issue in VS 2012. – jason Aug 18 '15 at 15:13
4

I used @ahsteele's approach (thanks and 2x+1s!), but was having one further error:-

.csproj : error : The operation could not be completed. Invalid class string

I can't find any citations for the real cause of that, but I was able to get VS2012RTM to load the project successfully by changing the <ProjectGuid>. (No idea how this happened - its part of a large solution and VS08, VS10, VS11 Beta and VS2012RC have all upgraded the .csproj and .sln over time.

Ruben Bartelink
  • 55,135
  • 22
  • 172
  • 222
1

In VS2017 the solution is to just make it like <ProjectTypeGuids></ProjectTypeGuids> so.

No Spaces in between ladies and gentlemen, otherwise it will waste 48 hours of your time.

Regards

WickStargazer
  • 394
  • 1
  • 10