简体   繁体   中英

How to recover corrupted xaml.cs file?

i'm developing WPF windows application. 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. 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.

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

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. 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. BAML has an almost bijective relation to XAML, so it can be decompiled with relative ease back to the starting 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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