崩溃后恢复 .CS 类文件

发布于 2024-12-07 17:42:30 字数 146 浏览 0 评论 0原文

我正在 Visual Studio 2010 上上课,突然我的电脑崩溃了。当我重新启动计算机后。我启动 Visual Studio,发现该类完全是空的。 课前包含了1000多行代码。 无论如何我可以恢复该文件吗?

请帮忙,因为我没有它的另一份副本(我真是愚蠢)

I was working on a class in visual studio 2010 when suddenly my computer crashes. after I restart the computer. I start Visual studio and I find that class to be completely empty.
it contained more than 1000 lines of codes before the class.
is there anyway i can recover that file?

Help please because I don't have another copy of it (Stupid of me)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

暖树树初阳… 2024-12-14 17:42:31

如果找不到源代码文件,请尝试使用 Reflector 反编译包含该文件的最新构建的 dll班级。它不会给你完整的来源,但至少会给你一些开始的东西。

注意:Reflector 不再免费;如果这很重要,请尝试使用 JetBrains 的 dotPeek

另外,考虑使用源代码控制系统。这将允许您将代码版本“提交”到存储库,这样您就可以获得一个副本,以防将来发生类似的情况。

SubversionGitMercurial 是流行的;在我看来,Subversion 是最容易上手的,尤其是 TortoiseSVN (操作系统集成)和 AnkhSVN(Visual Studio 集成)。如果您不想担心设置存储库/服务器,请查看托管解决方案,例如 Beanstalk,它提供 Subversion 和 Git,并让您可以使用免费的有限帐户进行试用。

祝你好运 - 我希望你能够恢复你的来源!

If you cannot find the source code file, try using Reflector to decompile the most recently built dll you have containing that class. It won't give you your complete source, but at least will give you something to start with.

Note: Reflector is no longer free; if that matters, try dotPeek from JetBrains instead.

Also, look into using a source code control system. This will let you 'commit' versions of your code to a repository, so you'll have a copy in case something like this happens in the future.

Subversion, Git, and Mercurial are popular ones; In my opinion, Subversion would be the easiest to start out with, especially with TortoiseSVN (OS integration) and AnkhSVN (Visual Studio integration). If you don't want to worry about setting up a repository/server, look into a hosted solution, like Beanstalk, which offers Subversion and Git and lets you try it out with a free, limited account.

Good luck - I hope you are able to recover your source!

傲影 2024-12-14 17:42:31

对我有用的东西是备份。
顺便说一句,我试图在 Windows 8 机器上恢复 VS2013 文件。

尝试检查系统中的以下位置。

C:\Users\username\My Documents\Visual Studio \Backup Files\ProjectFolder

我找到了一个原始文件,其名称为original-date.filename.cs 和一个recovered-date.filename.cs 文件。

原来的就是所需要的。
删除项目中的一个,添加原来的文件并重命名为file.cs。尝试构建和调试,得到了预期的结果。

Something which worked for me was back-up.
BTW I was trying to recover a VS2013 file on a Windows 8 machine.

Try to check in below location in your system.

C:\Users\username\My Documents\Visual Studio \Backup Files\ProjectFolder

I found an original file with original-date.filename.cs name and a recovered-date.filename.cs files.

The original was the one needed.
Deleted the one in project, added the original file and renamed it to file.cs. Tried building and debugging and it gave the expected results.

总以为 2024-12-14 17:42:31

还想再补充一件事......
就我而言,我有一个aspx页面及其各自的.cs和designer.cs
.cs 文件已损坏,我确实在项目上进行了构建,使用 Designer.cs 项目已成功构建,并且 dll 已被替换。当我尝试使用反射器恢复时,一切都处于无法返回的状态。 :(

因此,如果您发现任何文件已损坏,请不要构建项目。

Also just want to add one more thing...
In my case i had an aspx page with its respective .cs and designer.cs
The .cs file got corrupted and I did build on project, with the designer.cs the project got build successfully and the dll got replaced. And when i tried to recover using reflector everything was in a state no return. :(

So don't build the project if you see any file got corrupted.

大海や 2024-12-14 17:42:31

的文件中找到该文件

在 Visual Studio 2019 中,我在带有 TMP 扩展名FileName.cs~xxxxxxxx.TMP

in visual studio 2019 I find the file in a files with TMP extension

FileName.cs~xxxxxxxx.TMP

浅听莫相离 2024-12-14 17:42:31

当 Visual Studio 崩溃或系统意外关闭时,这种情况也发生在我身上几次。您可以使用 Recuva。它不会每次都恢复文件,但在大多数情况下它都能完美工作。

以下是恢复之前需要配置的设置。

  1. 启动雷库瓦。如果向导启动,请进入高级模式。
  2. 单击选项。
  3. 在“选项”对话框中,单击“操作”选项卡。
  4. 单击“扫描未删除的文件”,然后单击“确定”。
  5. 正常运行 Recuva 扫描。未删除的文件用绿色双圆状态图标指示。

希望您会在恢复的文件中找到损坏的文件,因为它恢复了该文件的多个版本。

This happened to me a few times as well when Visual Studio was crashed or System was shutdown unexpectedly.You can recover these corrupted file using Recuva. It dose not recover the file every time but in most of the cases it's work perfectly.

Below are the settings which you need to configure before recovery.

  1. Start Recuva. Enter Advanced mode if the Wizard launches.
  2. Click Options.
  3. In the Options dialog box, click the Actions tab.
  4. Click Scan for non-deleted files, and then click OK.
  5. Run the Recuva scan as normal. Non-deleted files are indicated with a green double-circle status icon.

Hopefully, you will find your corrupted file in recovered files as it recover multiple versions for that file.

愁杀 2024-12-14 17:42:31

非常有用的问题。我的电脑突然关闭时遇到文件崩溃的问题。使用“Recuva”(下载链接:https://filehippo.com/download_recuva/)软件恢复文件。扫描未删除的文件很有帮助。

我得到了帮助: https://www.samnoble.co.uk/2014/11/30/visual-studio-crashes-and-a-corrupted-cs-file/

Very useful question. I got issue of file crash on sudden shutdown of my PC. recovered file using "Recuva"(download link: https://filehippo.com/download_recuva/) software. Scan for non-deleted files was helpful.

I got help from: https://www.samnoble.co.uk/2014/11/30/visual-studio-crashes-and-a-corrupted-cs-file/

罪#恶を代价 2024-12-14 17:42:31

嗯,这件事最近发生在我身上,我确实通过这种方式拿回了我的文件。

1. Find the project DLLs in the bin folder. Example MySolution.dll
2. Download and Install .Net Reflector from https://www.red-gate.com/products/dotnet-development/reflector/trial/thank-you
3. Open the .Net Reflector app and click the open folder icon then move to your bin directory and select MySolution.dll file
4. Then traverse and expand through your namespaces and classes to look into your codes.
5. Have fun! 

Well, that happen recently for me and I did get my file back this way.

1. Find the project DLLs in the bin folder. Example MySolution.dll
2. Download and Install .Net Reflector from https://www.red-gate.com/products/dotnet-development/reflector/trial/thank-you
3. Open the .Net Reflector app and click the open folder icon then move to your bin directory and select MySolution.dll file
4. Then traverse and expand through your namespaces and classes to look into your codes.
5. Have fun! 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文