如何在 Visual Studio 2012 或 Visual Studio 2013 中打开旧的 MVC 项目? [英] How do I open an old MVC project in Visual Studio 2012 or Visual Studio 2013?

查看:20
本文介绍了如何在 Visual Studio 2012 或 Visual Studio 2013 中打开旧的 MVC 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的 ASP.NET MVC 2 项目,我不想升级到 MVC 3 或 MVC 4.我正在一台运行 Windows 8、Visual Studio 2012 和 Visual Studio 2013 的新机器上工作.当我尝试在 VS 2012 或 VS 2013 中打开 MVC 2 项目我收到错误:

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:

此项目与当前版本的 Visual Studio 不兼容

This project is incompatible with the current edition of Visual Studio

然后该项目将在解决方案资源管理器中卸载并显示为灰色.我不想安装 Visual Studio 的另一个副本.如何在新版本的 Visual Studio 中打开旧的 MVC 项目?

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?

推荐答案

中打开不受支持的 MVC 项目Visual Studio 2012 或 Visual Studio 2013 实际上很容易通过两个步骤完成.事实上,正如 bytebender 的评论表明,这些相同的步骤应该适用于并适用于 MVC 1 项目.但是,我没有对它们进行测试,因此不能保证它们确实有效.

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.

假设您还没有这样做,那么第一步是下载并安装 MVC 1MVC 2MVC 3(在启动之前关闭 Visual Studio安装).

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).

一旦您安装了适当风格的 MVC,该项目仍不会在 VS 2012 中加载.这是因为 ASP.NET MVC 项目是一个 项目子类型.这意味着该项目在 Visual Studio 中使用时具有可用的附加插件和功能.

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.

Visual Studio 2012 和 Visual Studio 2013 与 ASP.NET MVC 和其他项目类型的向后兼容性都受到限制.不幸的是,安装旧的 MVC 位并没有改变这一点.Visual Studio 2012 兼容使用 ASP.NET MVC 3 和 4 项目风格.Visual Studio 2013 与 MVC 4 和 MVC 5 兼容.

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.

要加载项目,您必须修改项目文件.为此,右键单击卸载的项目并选择编辑.这会将项目文件作为 XML 文本文件打开.找到 ProjectTypeGuids 节点,它应该看起来像这样:

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} (如上例所示)
  • ASP.NET MVC 3:{E53F8FEA-EAE0-44A6-8774-FFD645390401}
  • ASP.NET MVC 4:{E3E379DF-F4C6-4180-9B81-6769533ABE47}

删除适当的 GUID 后,ProjectTypeGuids 应该类似于:

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

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

保存文件并关闭 Visual Studio 项目文件编辑器.右键单击项目并选择重新加载.如果项目没有重新加载,请关闭并重新打开 Visual Studio.您现在应该可以在新版本的 Visual Studio 中使用旧的 ASP.NET MVC 项目.

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.

需要注意的重要一点是,经过这些修改后,Visual Studio 不知道这是一个 ASP.NET MVC 项目;因此,项目特定的功能,如添加控制器、视图等".不会出现在菜单中.

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.

这篇关于如何在 Visual Studio 2012 或 Visual Studio 2013 中打开旧的 MVC 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆