简体   繁体   English

如何恢复损坏的xaml.cs文件?

[英]How to recover corrupted xaml.cs file?

i'm developing WPF windows application. 我正在开发WPF Windows应用程序。 due to sudden restart of my PC one of my xaml.cs file get corrupt.i can't find any coding in my xaml.cs file. 由于我的PC突然重启,我的xaml.cs文件之一损坏了。我在我的xaml.cs文件中找不到任何编码。 while viewing its empty page.please let me know how to recover my coding. 同时查看其空白页。请让我知道如何恢复编码。

Unfortunately unless you use source control or something similar then the chances are you have lost your file completely. 不幸的是,除非您使用源代码控制或类似方法,否则您可能会完全丢失文件。

It is unlikely for your program to have stored a copy before your pc restarted, all I can say is if you have source control then the answer would be to look in there. 在您的PC重新启动之前,您的程序不太可能存储副本,我只能说,如果您具有源代码控制,那么答案就是在其中查看。

The only other thing I can say is always save your work as you go along! 我只能说的另一件事是, 一路走来,总是要保存您的工作! take it as second nature, do a block/even a line of code, save, etc. 将其视为第二本性,执行块/甚至一行代码,保存等。

Edit 编辑

You say you were using VS2010, You could check C:\\Documents and Settings\\UserName\\My Documents\\Visual Studio 2010\\Backup Files\\ (or the equivalent on your system). 您说您正在使用VS2010,可以检查C:\\ Documents and Settings \\ UserName \\ My Documents \\ Visual Studio 2010 \\ Backup Files \\(或系统上的等效文件)。

This would only work if you have back up switched on! 仅在备份已打开的情况下才有效!

If there are still files in your build directory - bin/debug or bin/release - then you could try examining the DLLs/EXEs with a reflection tool to recover some of the structures and potentially the code. 如果您的构建目录中仍然有文件-bin / debug或bin / release-那么您可以尝试使用反射工具检查DLL / EXE,以恢复某些结构和潜在的代码。 It won't be perfect but it is better than nothing if it is a significant amount of work. 它不是完美的,但是如果要进行大量工作,总比没有好。

C# and VB are compiled into MSIL which can be decompiled, and XAML is saved as BAML (a compressed form of XAML) as a resource in the assembly. C#和VB被编译为MSIL,可以反编译,并且XAML作为BAML(XAML的压缩形式)作为程序集中的资源保存。 BAML has an almost bijective relation to XAML, so it can be decompiled with relative ease back to the starting XAML. BAML与XAML具有几乎双射的关系,因此可以相对容易地反编译为起始XAML。 You'll lose whitespace and comments but I think that's it. 您会丢失空格和注释,但我认为就是这样。 I've done this myself before when I lost a XAML file and I was very relieved with the results. 在丢失XAML文件之前,我自己做了此操作,结果让我感到非常满意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM