如何在Visual Studio 2010中恢复损坏的.csproj文件? [英] How can I recover a corrupt .csproj file in Visual Studio 2010?

查看:636
本文介绍了如何在Visual Studio 2010中恢复损坏的.csproj文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电脑

Windows 8预览版

适用于Windows Phone的Visual Studio 2010 Express


我的应用程序位于

解决方案A

项目B

My PC
Windows 8 Preview Release
Visual Studio 2010 Express for Windows Phone

My App is in
Solution A
Project B

故事

当我键入代码时,屏幕冻结

关闭计算机电源,然后重新启动

当我在VS2010中为wp加载sln时

VS2010表示

Story
The screen is freezing when I type codes
I power off the PC then restart
When I load the sln in VS2010 for wp
VS2010 said


解决方案A(0个项目)

项目B(无法使用)

无法加载项目文件

"Solution A (0 projects)
Project B (unavailable)
The project file cannot be loaded

所以我尝试在编辑B.csproj中VS2010,它显示错误

So I tried to "Edit B.csproj" in VS2010, it shows error


B.csproj:错误:无法读取项目文件 B.csproj。

B.csproj:无法加载项目文件。缺少根元素。

B.csproj : error : Unable to read the project file 'B.csproj'.
B.csproj: The project file could not be loaded. Root element is missing.

帮助 >

如何正确打开我的解决方案?:(

Help
How can I open my solution correctly? :(

推荐答案

最简单的方法是可能会创建一个新的项目文件。最简单的方法是:

The easiest thing to do is probably to create a new project file. The simplest way to do this would be to:


  1. 打开Visual Studio的新副本

  2. 在与 B 相同类型的项目中,在另一个位置创建一个名称相同的项目。

  3. 关闭该Visual Studio副本

  4. 将新创建的 B.csproj 文件复制到您所有<$ c $来源的目录中c> B 是,覆盖现有的 B.csproj 文件(但请复制该文件,以防万一!)。

  5. 加载Visual Studio并打开解决方案 A

  1. Open a fresh copy of Visual Studio
  2. Create a project in a different location of the same type as B, with the same name.
  3. Close that copy of Visual Studio
  4. Copy the newly created B.csproj file to the directory where all your source for B is, overwriting the existing B.csproj file (but take a copy of it, just incase you need it!).
  5. Load Visual Studio and open Solution A.

您会注意到,该项目不包含您期望的任何文件/引用,并且可能包含对 Class1.cs 的损坏引用。或Visual Studio创建它时添加到新项目文件中的任何其他文件。现在:

You'll note that the project doesn't contain any of the files / references you'd expect and will probably contain a "broken" reference to Class1.cs or any other files that were added to the new project file when Visual Studio created it. Now:


  1. 确保在解决方案资源管理器中选择了项目B,然后单击显示所有文件图标。这是其中的三个文件重叠在一起的图片,位于刷新图标的左侧。

  2. 您将能够看到项目的所有内容,但变灰了。选择要添加回的每个文件/文件夹,右键单击并选择包含在项目中。

假设没有什么复杂的您的项目,现在只需要重新添加所有引用,它就可以编译并运行。您可以使用超越比较之类的工具来比较新项目文件和原始项目文件,以找出可能需要解决的其他问题

Assuming there's nothing too complicated about your project, you should only now need to re-add any References and it should compile and run. Any further things you can probably work out by using a tool like Beyond Compare to compare the new project file and the original project file to look for things you've missed.

如果您曾经,您将能够恢复项目文件的先前版本,而不必经历这种麻烦。您可以想到的几乎任何源代码控制解决方案都可以在PC上运行,而无需专用服务器。 VisualSVN服务器是最容易设置的,它可以免费用于个人商业用途。

If you were, you'd be able to recover a previous version of your project file and not have to go through this hassle. Pretty much any source control solution you can think of can be run on a PC without requiring a dedicated server. One of the easiest to setup is VisualSVN Server, which is free for personal and commercial use.

这篇关于如何在Visual Studio 2010中恢复损坏的.csproj文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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