如何在 Visual Studio 2010 中恢复损坏的 .csproj 文件?

编程入门 行业动态 更新时间:2024-10-17 00:19:04
本文介绍了如何在 Visual Studio 2010 中恢复损坏的 .csproj 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的电脑Windows 8 预览版适用于 Windows Phone 的 Visual Studio 2010 Express我的应用程序在方案一项目 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

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

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:

  • 打开 Visual Studio 的新副本
  • 在不同位置创建一个与B类型相同、名称相同的项目.
  • 关闭 Visual Studio 的副本
  • 将新创建的 B.csproj 文件复制到 B 的所有源所在的目录,覆盖现有的 B.csproj 文件(但请复制一份,以防万一你需要它!).
  • 加载 Visual Studio 并打开解决方案 A.
  • Open a fresh copy of Visual Studio
  • Create a project in a different location of the same type as B, with the same name.
  • Close that copy of Visual Studio
  • 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!).
  • 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:

  • 确保在解决方案资源管理器中选择了项目 B,然后单击显示所有文件"图标.这是一张有 3 个文件相互重叠的图片,位于刷新"图标的左侧.
  • 您将能够看到项目的所有内容,但显示为灰色".选择要添加回的每个文件/文件夹,右键单击并选择包含在项目中".
  • 假设您的项目没有什么太复杂的,您现在应该只需要重新添加任何引用并且它应该可以编译和运行.您可以使用Beyond Compare 之类的工具来比较新项目文件和要查找的原始项目文件,从而解决更多问题你错过的东西.

    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 文件?

    本文发布于:2023-06-06 01:38:08,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/531162.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:文件   如何在   Visual   Studio   csproj

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!