简体   繁体   中英

Visual studio 2010 empties the file on crash

I got a really bad problem while working on visual studio 2010. Accidently the power plug switched off and when I started the computer again the file was completly empty. I tried out following things:

  • I opened it in notepad and other couple of editors and it was empty.

  • I then opened it in Hex Editor. Hex editor shows that all bytes are set to 0.

  • I programatically read the file and it also showd all bytes set to 0.

  • Checked "Documents\Visual Studio 2010\Backup Files\" for my project and it was empty.

The file size is still showing in KBs but the code is completly gone.

Is there any possible way by which I can recover my code? If there is not, can anyone suggest me a setting/patch taht should be there so that it never happens again.

Note: I already have Autorecover option set for every 5 minutes in IDE.

Update : As suggested by Henok, If you have compiled and built the code at least once, you can reverse engineer the binary through reflector.

IIS has DLLs cached under C:\Windows\Microsoft.NET\v4.0.xyz\Temporary ASP.NET Files . Look for the dll and use a reflector. I use ILSpy.

Doesn't look like it, to stop in future though, save and save often. Also look at using subversion like svn, or Git.

Visual Studio still makes source files empty on sudden crashes, so I think I should share my solution.

Use any cloud file syncing service that supports file versions (for deleted files, too). Dropbox and Google Drive is what I can name. I randomly preferred Google Drive, though Dropbox can do all the same things.

I simply put my source tree in Google Drive, because it has file versions . My builds happen in Google Drive too, so there's much of unwanted traffic for big projects, but you can exclude some subfolders from syncing.

The drawback is that sometimes (in rare cases) Google Drive locks files and Visual Studio pops up "Save As..." dialog or some messages. You can usually close it, then save again successfuly. In very rare cases I had "The file is used by process" errors, and I had to restart Google Drive.

Save often and use source control. I use C.VS, personally.

It sounds like the IDE had the file(s) open for writing at byte 0 when the computer went down, clearing everything out.

Beyond your software problems, I suggest you manage your power plug in such a way that it won't be accidentally switched off.

Same thing happened to me and thought I would post it here for those who would come here for answers.

If you have compiled and built the code at least once, you can reverse engineer the binary. Reflector did the trick for me.

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